[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 01/18] Update common files with xenbus


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
  • Date: Fri, 16 Oct 2026 15:26:38 +0200
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID"
  • Cc: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
  • Delivery-date: Fri, 16 Oct 2026 13:27:11 +0000
  • Feedback-id: default:8631fc262581453bbf619ec5b2062170:Sweego
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

We sync these files with with xenbus which has up-to-date annotations and fixes
as xenvbd and xencrsh ones are old.

Signed-off-by: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
---
 src/common/util.h    |  87 ++++++++++++-----------
 src/xencrsh/assert.h | 158 ++++++++++++++++++++++++++++-------------
 src/xenvbd/assert.h  | 165 +++++++++++++++++--------------------------
 3 files changed, 220 insertions(+), 190 deletions(-)

diff --git a/src/common/util.h b/src/common/util.h
index e60ebbf..b197b14 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -38,12 +38,12 @@
 
 #include "assert.h"
 
-#define        P2ROUNDUP(_x, _a)   \
-        (-(-(_x) & -(_a)))
+#define        P2ROUNDUP(_t, _x, _a)   \
+        (-(-((_t)(_x)) & -(((_t)(_a)))))
 
 static FORCEINLINE LONG
 __ffs(
-    IN  unsigned long long  mask
+    _In_ unsigned long long mask
     )
 {
     unsigned char           *array = (unsigned char *)&mask;
@@ -82,14 +82,14 @@ __ffs(
 
 static FORCEINLINE VOID
 __CpuId(
-    IN  ULONG   Leaf,
-    OUT PULONG  EAX OPTIONAL,
-    OUT PULONG  EBX OPTIONAL,
-    OUT PULONG  ECX OPTIONAL,
-    OUT PULONG  EDX OPTIONAL
+    _In_ ULONG          Leaf,
+    _Out_opt_ PULONG    EAX,
+    _Out_opt_ PULONG    EBX,
+    _Out_opt_ PULONG    ECX,
+    _Out_opt_ PULONG    EDX
     )
 {
-    int         Value[4] = {0};
+    int                 Value[4] = {0};
 
     __cpuid(Value, Leaf);
 
@@ -108,12 +108,12 @@ __CpuId(
 
 static FORCEINLINE LONG
 __InterlockedAdd(
-    IN  LONG    *Value,
-    IN  LONG    Delta
+    _Inout_ LONG    *Value,
+    _In_ LONG       Delta
     )
 {
-    LONG        New;
-    LONG        Old;
+    LONG            New;
+    LONG            Old;
 
     do {
         Old = *Value;
@@ -125,12 +125,12 @@ __InterlockedAdd(
 
 static FORCEINLINE LONG
 __InterlockedSubtract(
-    IN  LONG    *Value,
-    IN  LONG    Delta
+    _Inout_ LONG    *Value,
+    _In_ LONG       Delta
     )
 {
-    LONG        New;
-    LONG        Old;
+    LONG            New;
+    LONG            Old;
 
     do {
         Old = *Value;
@@ -140,23 +140,24 @@ __InterlockedSubtract(
     return New;
 }
 
-__checkReturn
+_Check_return_
 static FORCEINLINE PVOID
 __AllocatePoolWithTag(
-    IN  POOL_TYPE   PoolType,
-    IN  SIZE_T      NumberOfBytes,
-    IN  ULONG       Tag
+    _In_ POOL_TYPE  PoolType,
+    _In_ SIZE_T     NumberOfBytes,
+    _In_ ULONG      Tag
     )
 {
     PUCHAR          Buffer;
 
-    __analysis_assume(PoolType == NonPagedPool ||
+    _Analysis_assume_(PoolType == NonPagedPool ||
                       PoolType == PagedPool);
 
     if (NumberOfBytes == 0)
         return NULL;
 
 #if (_MSC_VER >= 1928) // VS 16.9 (EWDK 20344 or later)
+#pragma warning(suppress:28160) // annotation error
     Buffer = ExAllocatePoolUninitialized(PoolType, NumberOfBytes, Tag);
 #else
 #pragma warning(suppress:28160) // annotation error
@@ -171,8 +172,8 @@ __AllocatePoolWithTag(
 
 static FORCEINLINE VOID
 __FreePoolWithTag(
-    IN  PVOID   Buffer,
-    IN  ULONG   Tag
+    _In_ PVOID  Buffer,
+    _In_ ULONG  Tag
     )
 {
     ExFreePoolWithTag(Buffer, Tag);
@@ -180,7 +181,7 @@ __FreePoolWithTag(
 
 static FORCEINLINE PMDL
 __AllocatePages(
-    IN  ULONG           Count
+    _In_ ULONG          Count
     )
 {
     PHYSICAL_ADDRESS    LowAddress;
@@ -249,10 +250,10 @@ fail1:
 
 static FORCEINLINE VOID
 __FreePages(
-    IN PMDL    Mdl
+    _In_ PMDL   Mdl
     )
 {
-    PUCHAR     MdlMappedSystemVa;
+    PUCHAR      MdlMappedSystemVa;
 
     ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     MdlMappedSystemVa = Mdl->MappedSystemVa;
@@ -265,15 +266,17 @@ __FreePages(
 
 #define __FreePage(_Mdl)    __FreePages(_Mdl)
 
-static FORCEINLINE PCHAR
+static FORCEINLINE PSTR
 __strtok_r(
-    IN      PCHAR   Buffer,
-    IN      PCHAR   Delimiter,
-    IN OUT  PCHAR   *Context
+    _Inout_opt_ PSTR    Buffer,
+    _In_ PSTR           Delimiter,
+    _When_(Buffer != NULL, _Outptr_)
+    _When_(Buffer == NULL, _Inout_)
+    PSTR                *Context
     )
 {
-    PCHAR           Token;
-    PCHAR           End;
+    PSTR                Token;
+    PSTR                End;
 
     if (Buffer != NULL)
         *Context = Buffer;
@@ -303,15 +306,17 @@ __strtok_r(
     return Token;
 }
 
-static FORCEINLINE PWCHAR
+static FORCEINLINE PWSTR
 __wcstok_r(
-    IN      PWCHAR  Buffer,
-    IN      PWCHAR  Delimiter,
-    IN OUT  PWCHAR  *Context
+    _Inout_opt_ PWSTR   Buffer,
+    _In_ PWSTR          Delimiter,
+    _When_(Buffer != NULL, _Outptr_)
+    _When_(Buffer == NULL, _Inout_)
+    PWSTR               *Context
     )
 {
-    PWCHAR          Token;
-    PWCHAR          End;
+    PWSTR               Token;
+    PWSTR               End;
 
     if (Buffer != NULL)
         *Context = Buffer;
@@ -343,7 +348,7 @@ __wcstok_r(
 
 static FORCEINLINE CHAR
 __toupper(
-    IN  CHAR    Character
+    _In_ CHAR   Character
     )
 {
     if (Character < 'a' || Character > 'z')
@@ -354,7 +359,7 @@ __toupper(
 
 static FORCEINLINE CHAR
 __tolower(
-    IN  CHAR    Character
+    _In_ CHAR   Character
     )
 {
     if (Character < 'A' || Character > 'Z')
diff --git a/src/xencrsh/assert.h b/src/xencrsh/assert.h
index b709a19..72ae0cc 100644
--- a/src/xencrsh/assert.h
+++ b/src/xencrsh/assert.h
@@ -1,34 +1,34 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- */ 
+ */
 
 #ifndef _XENCRSH_ASSERT_H
 #define _XENCRSH_ASSERT_H
@@ -38,12 +38,12 @@
 #include "log.h"
 
 static FORCEINLINE VOID
-__BugCheck(
-    IN  ULONG       Code,
-    IN  ULONG_PTR   Parameter1,
-    IN  ULONG_PTR   Parameter2,
-    IN  ULONG_PTR   Parameter3,
-    IN  ULONG_PTR   Parameter4
+__Bug(
+    _In_ ULONG      Code,
+    _In_ ULONG_PTR  Parameter1,
+    _In_ ULONG_PTR  Parameter2,
+    _In_ ULONG_PTR  Parameter3,
+    _In_ ULONG_PTR  Parameter4
     )
 {
 #pragma prefast(suppress:28159)
@@ -58,16 +58,16 @@ __BugCheck(
 
 #define BUG(_TEXT)                                              \
         do {                                                    \
-            const CHAR  *_Text = (_TEXT);                       \
-            const CHAR  *_File = __FILE__;                      \
+            PCSTR       _Text = (_TEXT);                       \
+            PCSTR       _File = __FILE__;                      \
             ULONG       _Line = __LINE__;                       \
                                                                 \
-            LogError("BUG: " _TEXT "\n");                       \
-            __BugCheck(ASSERTION_FAILURE,                       \
-                       (ULONG_PTR)_Text,                        \
-                       (ULONG_PTR)_File,                        \
-                       (ULONG_PTR)_Line,                        \
-                       0);                                      \
+            LogError("BUG: " _TEXT "\n");                          \
+            __Bug(ASSERTION_FAILURE,                            \
+                  (ULONG_PTR)_Text,                             \
+                  (ULONG_PTR)_File,                             \
+                  (ULONG_PTR)_Line,                             \
+                  0);                                           \
         } while (FALSE)
 
 #define BUG_ON(_EXP)                \
@@ -75,10 +75,21 @@ __BugCheck(
 
 #undef  ASSERT
 
+#if DBG
+
+#define __NT_ASSERT(_EXP)                                       \
+        ((!(_EXP)) ?                                            \
+        (LogError("ASSERTION FAILED: " #_EXP "\n"),                \
+         __annotation(L"Debug", L"AssertFail", L#_EXP),         \
+         DbgRaiseAssertionFailure(), FALSE) :                   \
+        TRUE)
+
+#define __ASSERT(_EXP)  __NT_ASSERT(_EXP)
+
 #define ASSERT(_EXP)                    \
         do {                            \
-            BUG_ON(_EXP);               \
-            __analysis_assume(_EXP);    \
+            __ASSERT(_EXP);             \
+            _Analysis_assume_(_EXP);    \
         } while (FALSE)
 
 #define ASSERT3U(_X, _OP, _Y)                       \
@@ -86,8 +97,8 @@ __BugCheck(
             ULONGLONG   _Lval = (ULONGLONG)(_X);    \
             ULONGLONG   _Rval = (ULONGLONG)(_Y);    \
             if (!(_Lval _OP _Rval)) {               \
-                LogError("%s = %llu\n", #_X, _Lval);\
-                LogError("%s = %llu\n", #_Y, _Rval);\
+                LogError("%s = %llu\n", #_X, _Lval);   \
+                LogError("%s = %llu\n", #_Y, _Rval);   \
                 ASSERT((_X) _OP (_Y));              \
             }                                       \
         } while (FALSE)
@@ -97,8 +108,8 @@ __BugCheck(
             LONGLONG    _Lval = (LONGLONG)(_X);     \
             LONGLONG    _Rval = (LONGLONG)(_Y);     \
             if (!(_Lval _OP _Rval)) {               \
-                LogError("%s = %lld\n", #_X, _Lval);\
-                LogError("%s = %lld\n", #_Y, _Rval);\
+                LogError("%s = %lld\n", #_X, _Lval);   \
+                LogError("%s = %lld\n", #_Y, _Rval);   \
                 ASSERT((_X) _OP (_Y));              \
             }                                       \
         } while (FALSE)
@@ -108,18 +119,45 @@ __BugCheck(
             PVOID   _Lval = (PVOID)(_X);            \
             PVOID   _Rval = (PVOID)(_Y);            \
             if (!(_Lval _OP _Rval)) {               \
-                LogError("%s = %p\n", #_X, _Lval);  \
-                LogError("%s = %p\n", #_Y, _Rval);  \
+                LogError("%s = %p\n", #_X, _Lval);     \
+                LogError("%s = %p\n", #_Y, _Rval);     \
                 ASSERT((_X) _OP (_Y));              \
             }                                       \
         } while (FALSE)
 
+#else   // DBG
+
+#pragma warning(disable:4100)
+#pragma warning(disable:4189)
+
+#define ASSERT(_EXP)                    \
+        do {                            \
+            _Analysis_assume_(_EXP);    \
+        } while (FALSE)
+
+#define ASSERT3U(_X, _OP, _Y)           \
+        ASSERT((_X) _OP (_Y))
+
+#define ASSERT3S(_X, _OP, _Y)           \
+        ASSERT((_X) _OP (_Y))
+
+#define ASSERT3P(_X, _OP, _Y)           \
+        ASSERT((_X) _OP (_Y))
+
+#endif  // DBG
+
+#ifndef TEST_MEMORY
+#define TEST_MEMORY DBG
+#endif
+
+#if TEST_MEMORY
+
 static __inline BOOLEAN
 _IsZeroMemory(
-    IN  const PCHAR Caller,
-    IN  const PCHAR Name,
-    IN  PVOID       Buffer,
-    IN  ULONG       Length
+    _In_ PCSTR          Caller,
+    _In_ PCSTR          Name,
+    _In_ PVOID          Buffer,
+    _In_ ULONG          Length
     )
 {
     ULONG           Offset;
@@ -136,6 +174,26 @@ _IsZeroMemory(
     return TRUE;
 }
 
+#else   // TEST_MEMORY
+
+static __inline BOOLEAN
+_IsZeroMemory(
+    _In_ PCSTR          Caller,
+    _In_ PCSTR          Name,
+    _In_ PVOID          Buffer,
+    _In_ ULONG          Length
+    )
+{
+    UNREFERENCED_PARAMETER(Caller);
+    UNREFERENCED_PARAMETER(Name);
+    UNREFERENCED_PARAMETER(Buffer);
+    UNREFERENCED_PARAMETER(Length);
+
+    return TRUE;
+}
+
+#endif  // TEST_MEMORY
+
 #define IsZeroMemory(_Buffer, _Length) \
         _IsZeroMemory(__FUNCTION__, #_Buffer, (_Buffer), (_Length))
 
diff --git a/src/xenvbd/assert.h b/src/xenvbd/assert.h
index 94e81fb..fe64a91 100644
--- a/src/xenvbd/assert.h
+++ b/src/xenvbd/assert.h
@@ -1,34 +1,34 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- */ 
+ */
 
 #ifndef _XENVBD_ASSERT_H
 #define _XENVBD_ASSERT_H
@@ -38,12 +38,12 @@
 #include "debug.h"
 
 static FORCEINLINE VOID
-__BugCheck(
-    __in  ULONG       Code,
-    __in_opt ULONG_PTR   Parameter1,
-    __in_opt ULONG_PTR   Parameter2,
-    __in_opt ULONG_PTR   Parameter3,
-    __in_opt ULONG_PTR   Parameter4
+__Bug(
+    _In_ ULONG      Code,
+    _In_ ULONG_PTR  Parameter1,
+    _In_ ULONG_PTR  Parameter2,
+    _In_ ULONG_PTR  Parameter3,
+    _In_ ULONG_PTR  Parameter4
     )
 {
 #pragma prefast(suppress:28159)
@@ -59,39 +59,21 @@ __BugCheck(
 
 #define BUG(_TEXT)                                              \
         do {                                                    \
-            const CHAR  *_Text = (_TEXT);                       \
-            const CHAR  *_File = __FILE__;                      \
+            PCSTR       _Text = (_TEXT);                       \
+            PCSTR       _File = __FILE__;                      \
             ULONG       _Line = __LINE__;                       \
                                                                 \
             Error("BUG: " _TEXT "\n");                          \
-            __BugCheck(ASSERTION_FAILURE,                       \
-                       (ULONG_PTR)_Text,                        \
-                       (ULONG_PTR)_File,                        \
-                       (ULONG_PTR)_Line,                        \
-                       0);                                      \
+            __Bug(ASSERTION_FAILURE,                            \
+                  (ULONG_PTR)_Text,                             \
+                  (ULONG_PTR)_File,                             \
+                  (ULONG_PTR)_Line,                             \
+                  0);                                           \
         } while (FALSE)
 
-#define BUG_MSG(_TEXT1, _TEXT2)                                 \
-        do {                                                    \
-            const CHAR  *_Text1 = (_TEXT1);                     \
-            const CHAR  *_Text2 = (_TEXT2);                     \
-            const CHAR  *_File = __FILE__;                      \
-            ULONG       _Line = __LINE__;                       \
-                                                                \
-            Error("BUG: " _TEXT1 " %s\n", _Text2);              \
-            __BugCheck(ASSERTION_FAILURE,                       \
-                       (ULONG_PTR)_Text1,                       \
-                       (ULONG_PTR)_File,                        \
-                       (ULONG_PTR)_Line,                        \
-                       (ULONG_PTR)_Text2);                      \
-        } while (FALSE)
-
-#define BUG_ON(_EXP)                           \
+#define BUG_ON(_EXP)                \
         if (_EXP) BUG(#_EXP)
 
-#define BUG_ON_MSG(_EXP, _TEXT)                \
-        if (_EXP) BUG_MSG(#_EXP, _TEXT)
-
 #undef  ASSERT
 
 #if DBG
@@ -103,26 +85,12 @@ __BugCheck(
          DbgRaiseAssertionFailure(), FALSE) :                   \
         TRUE)
 
-#define __NT_ASSERT_MSG(_EXP, _TEXT)                            \
-        ((!(_EXP)) ?                                            \
-        (Error("ASSERTION FAILED: " #_EXP " " #_TEXT "\n"),     \
-         __annotation(L"Debug", L"AssertFail", L#_EXP),         \
-         DbgRaiseAssertionFailure(), FALSE) :                   \
-        TRUE)
-
-#define __ASSERT(_EXP)              __NT_ASSERT(_EXP)
-#define __ASSERT_MSG(_EXP, _TEXT)   __NT_ASSERT_MSG(_EXP, _TEXT)
+#define __ASSERT(_EXP)  __NT_ASSERT(_EXP)
 
 #define ASSERT(_EXP)                    \
         do {                            \
             __ASSERT(_EXP);             \
-            __analysis_assume(_EXP);    \
-        } while (FALSE)
-
-#define ASSERT_MSG(_EXP, _TEXT)         \
-        do {                            \
-            __ASSERT_MSG(_EXP, _TEXT);  \
-            __analysis_assume(_EXP);    \
+            _Analysis_assume_(_EXP);    \
         } while (FALSE)
 
 #define ASSERT3U(_X, _OP, _Y)                       \
@@ -132,7 +100,7 @@ __BugCheck(
             if (!(_Lval _OP _Rval)) {               \
                 Error("%s = %llu\n", #_X, _Lval);   \
                 Error("%s = %llu\n", #_Y, _Rval);   \
-                ASSERT(_X _OP _Y);                  \
+                ASSERT((_X) _OP (_Y));              \
             }                                       \
         } while (FALSE)
 
@@ -143,7 +111,7 @@ __BugCheck(
             if (!(_Lval _OP _Rval)) {               \
                 Error("%s = %lld\n", #_X, _Lval);   \
                 Error("%s = %lld\n", #_Y, _Rval);   \
-                ASSERT(_X _OP _Y);                  \
+                ASSERT((_X) _OP (_Y));              \
             }                                       \
         } while (FALSE)
 
@@ -154,18 +122,7 @@ __BugCheck(
             if (!(_Lval _OP _Rval)) {               \
                 Error("%s = %p\n", #_X, _Lval);     \
                 Error("%s = %p\n", #_Y, _Rval);     \
-                ASSERT(_X _OP _Y);                  \
-            }                                       \
-        } while (FALSE)
-
-#define ASSERTREFCOUNT(_X, _OP, _Y, _Z)             \
-        do {                                        \
-            LONG    _L = (LONG)(_X);                \
-            LONG    _R = (LONG)(_Y);                \
-            if (!(_L _OP _R)) {                     \
-                Error("%s:%s = %d\n", (_Z), #_X, _L); \
-                Error("%s:%s = %d\n", (_Z), #_Y, _R); \
-                ASSERT_MSG(_X _OP _Y, (_Z));        \
+                ASSERT((_X) _OP (_Y));              \
             }                                       \
         } while (FALSE)
 
@@ -176,7 +133,7 @@ __BugCheck(
 
 #define ASSERT(_EXP)                    \
         do {                            \
-            __analysis_assume(_EXP);    \
+            _Analysis_assume_(_EXP);    \
         } while (FALSE)
 
 #define ASSERT3U(_X, _OP, _Y)           \
@@ -188,9 +145,6 @@ __BugCheck(
 #define ASSERT3P(_X, _OP, _Y)           \
         ASSERT((_X) _OP (_Y))
 
-#define ASSERTREFCOUNT(_X, _OP, _Y, _Z) \
-        ASSERT((_X) _OP (_Y))
-
 #endif  // DBG
 
 #ifndef TEST_MEMORY
@@ -199,13 +153,12 @@ __BugCheck(
 
 #if TEST_MEMORY
 
-__checkReturn
 static __inline BOOLEAN
 _IsZeroMemory(
-    __in const PCHAR Caller,
-    __in const PCHAR Name,
-    __in PVOID       Buffer,
-    __in ULONG       Length
+    _In_ PCSTR          Caller,
+    _In_ PCSTR          Name,
+    _In_ PVOID          Buffer,
+    _In_ ULONG          Length
     )
 {
     ULONG           Offset;
@@ -222,15 +175,29 @@ _IsZeroMemory(
     return TRUE;
 }
 
-#define IsZeroMemory(_Buffer, _Length) \
-        _IsZeroMemory(__FUNCTION__, #_Buffer, (_Buffer), (_Length))
-
 #else   // TEST_MEMORY
 
-#define IsZeroMemory(_Buffer, _Length)  TRUE
+static __inline BOOLEAN
+_IsZeroMemory(
+    _In_ PCSTR          Caller,
+    _In_ PCSTR          Name,
+    _In_ PVOID          Buffer,
+    _In_ ULONG          Length
+    )
+{
+    UNREFERENCED_PARAMETER(Caller);
+    UNREFERENCED_PARAMETER(Name);
+    UNREFERENCED_PARAMETER(Buffer);
+    UNREFERENCED_PARAMETER(Length);
+
+    return TRUE;
+}
 
 #endif  // TEST_MEMORY
 
+#define IsZeroMemory(_Buffer, _Length) \
+        _IsZeroMemory(__FUNCTION__, #_Buffer, (_Buffer), (_Length))
+
 #define IMPLY(_X, _Y)   (!(_X) || (_Y))
 #define EQUIV(_X, _Y)   (IMPLY((_X), (_Y)) && IMPLY((_Y), (_X)))
 
-- 
2.55.0.windows.5



--
Césaire Mounah | Vates Windows Guest Tools Engineer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.