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

[PATCH 3/4] Fix CodeQL warnings


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Thu, 12 Aug 2021 13:41:37 +0100
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Thu, 12 Aug 2021 12:42:16 +0000
  • Ironport-hdrordr: A9a23:mhzSOKHZqJhGEOQMpLqE7seALOsnbusQ8zAXP0AYc3Nom6uj5q eTdZUgpGbJYVkqOU3I9ersBEDEewK/yXcX2/h0AV7BZmnbUQKTRekIh7cKgQeQfhEWntQts5 uIGJIRNDSfNzRHZL7BkWqFL+o=
  • Ironport-sdr: Zbo57xjTw35n4acwDrUYA3kcl40RgjxC1lXJ/2KVtmko/gaD1bR/sA+RiPLGRdPpEbpqyzskKZ aSoMep5OODG/mJI0fCSkBGKoF+nedMnbZj8vTyzl/L6KXtJ5l3Hz1Ml5bMOi1jaPFatVGyW1hH PiA0xYSZITBBgBnN5WIBA+IbLocp3pu8QDCIiVYHd/noPhcIZz1FFJ8ZWO2udkeVSM0sfR/Knj 5SrtDG6dMviNvJiCzais6MZbiuOlc3y1+TBF3r/tcoRxrg05dDoiQNRgjubm5vGuyPg+CYUbJv A4bP5Gqf7n8hcp1UgguX4lf1
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

- ExAllocatePoolWithTag is deprecated in Win10 2004, use
    ExAllocatePoolUninitialized instead

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/common/util.h    |  4 ++++
 src/xenvbd/adapter.c | 12 ++++--------
 src/xenvbd/base64.c  | 15 ++++-----------
 3 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/src/common/util.h b/src/common/util.h
index eddad4a..36a36dd 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -151,8 +151,12 @@ __AllocatePoolWithTag(
     __analysis_assume(PoolType == NonPagedPool ||
                       PoolType == PagedPool);
 
+#if (_MSC_VER >= 1928) // VS 16.9 (EWDK 20344 or later)
+    Buffer = ExAllocatePoolUninitialized(PoolType, NumberOfBytes, Tag);
+#else
 #pragma warning(suppress:28160) // annotation error
     Buffer = ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag);
+#endif
     if (Buffer == NULL)
         return NULL;
 
diff --git a/src/xenvbd/adapter.c b/src/xenvbd/adapter.c
index 9fd2abc..5b17a6b 100644
--- a/src/xenvbd/adapter.c
+++ b/src/xenvbd/adapter.c
@@ -102,13 +102,9 @@ __AdapterAllocate(
     IN  ULONG   Size
     )
 {
-    PVOID       Buffer;
-    Buffer = ExAllocatePoolWithTag(NonPagedPool,
-                                   Size,
-                                   ADAPTER_POOL_TAG);
-    if (Buffer)
-        RtlZeroMemory(Buffer, Size);
-    return Buffer;
+    return __AllocatePoolWithTag(NonPagedPool,
+                                 Size,
+                                 ADAPTER_POOL_TAG);
 }
 
 static FORCEINLINE VOID
@@ -116,7 +112,7 @@ __AdapterFree(
     IN  PVOID   Buffer
     )
 {
-    ExFreePoolWithTag(Buffer, ADAPTER_POOL_TAG);
+    __FreePoolWithTag(Buffer, ADAPTER_POOL_TAG);
 }
 
 static FORCEINLINE PANSI_STRING
diff --git a/src/xenvbd/base64.c b/src/xenvbd/base64.c
index 0e62784..223579a 100644
--- a/src/xenvbd/base64.c
+++ b/src/xenvbd/base64.c
@@ -44,15 +44,9 @@ Base64Allocate(
     IN  ULONG   Size
     )
 {
-    PVOID       Buffer;
-
-    Buffer = ExAllocatePoolWithTag(NonPagedPool,
-                                   Size,
-                                   BASE64_POOL_TAG);
-    if (Buffer)
-        RtlZeroMemory(Buffer, Size);
-
-    return Buffer;
+    return __AllocatePoolWithTag(NonPagedPool,
+                                 Size,
+                                 BASE64_POOL_TAG);
 }
 
 VOID
@@ -60,8 +54,7 @@ Base64Free(
     IN  PVOID   Buffer
     )
 {
-    if (Buffer)
-        ExFreePoolWithTag(Buffer, BASE64_POOL_TAG);
+    __FreePoolWithTag(Buffer, BASE64_POOL_TAG);
 }
 
 static FORCEINLINE UCHAR
-- 
2.31.1.windows.1




 


Rackspace

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