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

[PATCH] Don't evaluate ASSERT3 arguments in release build


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Tu Dinh" <ngoc-tu.dinh@xxxxxxxxxx>
  • Date: Fri, 17 Apr 2026 10:04:54 +0000
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@xxxxxxxxxx" header.h="From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
  • Cc: "Owen Smith" <owen.smith@xxxxxxxxxx>, "Tu Dinh" <ngoc-tu.dinh@xxxxxxxxxx>
  • Delivery-date: Fri, 17 Apr 2026 10:05:00 +0000
  • Feedback-id: 30504962:30504962.20260417:md
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

Evaluating arguments to ASSERT3 may call functions that, even if they
don't have visible side effects (e.g. KeGetCurrentIrql), still cause
the function's code to be emitted into the binary.

Move the evaluation into inside the __analysis_assume expression to
avoid this.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
 src/xenvif/assert.h | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/src/xenvif/assert.h b/src/xenvif/assert.h
index d0cf3f2..c41dfed 100644
--- a/src/xenvif/assert.h
+++ b/src/xenvif/assert.h
@@ -136,29 +136,14 @@ __Bug(
             __analysis_assume(_EXP);    \
         } while (FALSE)
 
-#define ASSERT3U(_X, _OP, _Y)                       \
-        do {                                        \
-            ULONGLONG   _Lval = (ULONGLONG)(_X);    \
-            ULONGLONG   _Rval = (ULONGLONG)(_Y);    \
-                                                    \
-            __analysis_assume(_Lval _OP _Rval);     \
-        } while (FALSE)
+#define ASSERT3U(_X, _OP, _Y)           \
+        ASSERT((ULONGLONG)(_X) _OP (ULONGLONG)(_Y))
 
-#define ASSERT3S(_X, _OP, _Y)                       \
-        do {                                        \
-            LONGLONG    _Lval = (LONGLONG)(_X);     \
-            LONGLONG    _Rval = (LONGLONG)(_Y);     \
-                                                    \
-            __analysis_assume(_Lval _OP _Rval);     \
-        } while (FALSE)
+#define ASSERT3S(_X, _OP, _Y)           \
+        ASSERT((LONGLONG)(_X) _OP (LONGLONG)(_Y))
 
-#define ASSERT3P(_X, _OP, _Y)                       \
-        do {                                        \
-            PVOID   _Lval = (PVOID)(_X);            \
-            PVOID   _Rval = (PVOID)(_Y);            \
-                                                    \
-            __analysis_assume(_Lval _OP _Rval);     \
-        } while (FALSE)
+#define ASSERT3P(_X, _OP, _Y)           \
+        ASSERT((PVOID)(_X) _OP (PVOID)(_Y))
 
 #endif  // DBG
 
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

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®.