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

[win-pv-devel] [PATCH] Fix VS2013 SDV failures



Also update the assert.h header.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xeniface/assert.h   | 67 ++++++++++++++++++++++++++++++++++++-------------
 src/xeniface/registry.c | 38 +++++++++++++++++-----------
 src/xeniface/wmi.c      |  8 +++++-
 3 files changed, 80 insertions(+), 33 deletions(-)

diff --git a/src/xeniface/assert.h b/src/xeniface/assert.h
index 4229f7c..83b215f 100644
--- a/src/xeniface/assert.h
+++ b/src/xeniface/assert.h
@@ -37,7 +37,7 @@
 #include "log.h"
 
 static FORCEINLINE VOID
-__BugCheck(
+__Bug(
     IN  ULONG       Code,
     IN  ULONG_PTR   Parameter1,
     IN  ULONG_PTR   Parameter2,
@@ -62,11 +62,11 @@ __BugCheck(
             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_ON(_EXP)                \
@@ -98,7 +98,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)
 
@@ -109,7 +109,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)
 
@@ -120,16 +120,34 @@ __BugCheck(
             if (!(_Lval _OP _Rval)) {               \
                 Error("%s = %p\n", #_X, _Lval);     \
                 Error("%s = %p\n", #_Y, _Rval);     \
-                ASSERT(_X _OP _Y);                  \
+                ASSERT((_X) _OP (_Y));              \
             }                                       \
         } while (FALSE)
 
 #else   // DBG
 
-#define ASSERT(_EXP)
-#define ASSERT3U(_X, _OP, _Y)
-#define ASSERT3S(_X, _OP, _Y)
-#define ASSERT3P(_X, _OP, _Y)
+static FORCEINLINE VOID
+_IgnoreAssertion(
+    IN  BOOLEAN Value
+    )
+{
+    UNREFERENCED_PARAMETER(Value);
+}
+
+#define ASSERT(_EXP)                        \
+        do {                                \
+            _IgnoreAssertion(_EXP);         \
+            __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
 
@@ -161,17 +179,30 @@ _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  const PCHAR Caller,
+    IN  const PCHAR 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)))
 
 #endif  // _XENIFACE_ASSERT_H
-
diff --git a/src/xeniface/registry.c b/src/xeniface/registry.c
index 5843ef5..519d3f6 100644
--- a/src/xeniface/registry.c
+++ b/src/xeniface/registry.c
@@ -168,16 +168,16 @@ RegistryOpenHardwareKey(
         goto fail1;
 
     Length = 0;
-    (VOID) ZwQueryKey(SubKey,
-                      KeyNameInformation,
-                      NULL,
-                      0,
-                      &Length);
-
-    status = STATUS_INVALID_PARAMETER;
-    if (Length == 0)
+    status = ZwQueryKey(SubKey,
+                        KeyNameInformation,
+                        NULL,
+                        0,
+                        &Length);
+    if (status != STATUS_BUFFER_OVERFLOW &&
+        status != STATUS_BUFFER_TOO_SMALL)
         goto fail2;
-    
+
+#pragma prefast(suppress:6102)
     Info = __RegistryAllocate(Length + sizeof (WCHAR));
 
     status = STATUS_NO_MEMORY;
@@ -362,9 +362,11 @@ RegistryEnumerateSubKeys(
                         NULL,
                         0,
                         &Size);
-    if (status != STATUS_BUFFER_TOO_SMALL)
+    if (status != STATUS_BUFFER_OVERFLOW &&
+        status != STATUS_BUFFER_TOO_SMALL)
         goto fail1;
 
+#pragma prefast(suppress:6102)
     Full = __RegistryAllocate(Size);
 
     status = STATUS_NO_MEMORY;
@@ -463,9 +465,11 @@ RegistryEnumerateValues(
                         NULL,
                         0,
                         &Size);
-    if (status != STATUS_BUFFER_TOO_SMALL)
+    if (status != STATUS_BUFFER_OVERFLOW &&
+        status != STATUS_BUFFER_TOO_SMALL)
         goto fail1;
 
+#pragma prefast(suppress:6102)
     Full = __RegistryAllocate(Size);
 
     status = STATUS_NO_MEMORY;
@@ -596,9 +600,11 @@ RegistryQueryDwordValue(
                              NULL,
                              0,
                              &Size);
-    if (status != STATUS_BUFFER_TOO_SMALL)
+    if (status != STATUS_BUFFER_OVERFLOW &&
+        status != STATUS_BUFFER_TOO_SMALL)
         goto fail2;
 
+#pragma prefast(suppress:6102)
     Partial = __RegistryAllocate(Size);
 
     status = STATUS_NO_MEMORY;
@@ -821,9 +827,11 @@ RegistryQuerySzValue(
                              NULL,
                              0,
                              &Size);
-    if (status != STATUS_BUFFER_TOO_SMALL)
+    if (status != STATUS_BUFFER_OVERFLOW &&
+        status != STATUS_BUFFER_TOO_SMALL)
         goto fail2;
 
+#pragma prefast(suppress:6102)
     Value = __RegistryAllocate(Size);
 
     status = STATUS_NO_MEMORY;
@@ -892,10 +900,12 @@ RegistryQueryKeyName(
                         NULL,
                         0,
                         &Size);
-    if (status != STATUS_BUFFER_TOO_SMALL)
+    if (status != STATUS_BUFFER_OVERFLOW &&
+        status != STATUS_BUFFER_TOO_SMALL)
         goto fail1;
 
     // Name information is not intrinsically NULL terminated
+#pragma prefast(suppress:6102)
     Value = __RegistryAllocate(Size + sizeof (WCHAR));
 
     status = STATUS_NO_MEMORY;
diff --git a/src/xeniface/wmi.c b/src/xeniface/wmi.c
index bbdb780..4285ada 100644
--- a/src/xeniface/wmi.c
+++ b/src/xeniface/wmi.c
@@ -1159,7 +1159,13 @@ CreateNewSession(XENIFACE_FDO *fdoData,
     fdoData->Sessions++;
     UnlockSessions(fdoData);
     InitializeObjectAttributes(&oa, NULL, OBJ_KERNEL_HANDLE, NULL, NULL);
-    (VOID) PsCreateSystemThread(&hthread, THREAD_ALL_ACCESS, &oa, NULL, NULL, 
WatchCallbackThread, session);
+
+    status = PsCreateSystemThread(&hthread, THREAD_ALL_ACCESS, &oa, NULL, 
NULL, WatchCallbackThread, session);
+    if (!NT_SUCCESS(status)) {
+            RtlFreeAnsiString(&ansi); 
+            ExFreePool(session);
+            return status;
+    }
     ObReferenceObjectByHandle(hthread, THREAD_ALL_ACCESS, NULL, KernelMode,  
&session->WatchThread, NULL);
     RtlFreeAnsiString(&ansi);
     return STATUS_SUCCESS;
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

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