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

[PATCH 03/17] util: fix some annotations


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
  • Date: Mon, 5 Oct 2026 14:07:44 +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: Mon, 05 Oct 2026 12:08:04 +0000
  • Feedback-id: default:8631fc262581453bbf619ec5b2062170:Sweego
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

* _InterlockedAdd() and _InterlockedSubstract() call
InterlockedCompareExchange(Value, New, Old), however the signature of
InterlockedCompareExchange is annotated as (_Inout_, _In_, _Out_)[1], so
Value should be annotated as _Inout_ in these functions as Value could be
updated.

* __strtok_r() indirectly write in Buffer
(*Context = Buffer, and later *Context = End).
So Buffer should be annotated as _Inout_opt_.

* functions using these are updated accordingly

[1]: 
https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-interlockedcompareexchange

Assisted-by: Claude/Opus-4
Signed-off-by: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
---
 src/xeniface/fdo.c  |  2 +-
 src/xeniface/util.h | 28 ++++++++++++++--------------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/xeniface/fdo.c b/src/xeniface/fdo.c
index e3f9b4f..aba717b 100644
--- a/src/xeniface/fdo.c
+++ b/src/xeniface/fdo.c
@@ -530,7 +530,7 @@ __FdoFreeAnsi(
 static FORCEINLINE BOOLEAN
 __FdoMatchDistribution(
     _In_ PXENIFACE_FDO  Fdo,
-    _In_ PCHAR          Buffer
+    _Inout_ PCHAR       Buffer
     )
 {
     PCHAR               Vendor;
diff --git a/src/xeniface/util.h b/src/xeniface/util.h
index 8c6a917..77daa07 100644
--- a/src/xeniface/util.h
+++ b/src/xeniface/util.h
@@ -108,8 +108,8 @@ __CpuId(
 
 static FORCEINLINE LONG
 __InterlockedAdd(
-    _In_ LONG   *Value,
-    _In_ LONG   Delta
+    _Inout_ LONG    *Value,
+    _In_ LONG       Delta
     )
 {
     LONG        New;
@@ -125,8 +125,8 @@ __InterlockedAdd(
 
 static FORCEINLINE LONG
 __InterlockedSubtract(
-    _In_ LONG   *Value,
-    _In_ LONG   Delta
+    _Inout_ LONG    *Value,
+    _In_ LONG       Delta
     )
 {
     LONG        New;
@@ -277,15 +277,15 @@ __FreePages(
 
 static FORCEINLINE PSTR
 __strtok_r(
-    _In_opt_ PSTR   Buffer,
-    _In_ PSTR       Delimiter,
+    _Inout_opt_ PSTR    Buffer,
+    _In_ PSTR           Delimiter,
     _When_(Buffer != NULL, _Outptr_)
     _When_(Buffer == NULL, _Inout_)
-    PSTR            *Context
+    PSTR                *Context
     )
 {
-    PSTR            Token;
-    PSTR            End;
+    PSTR                Token;
+    PSTR                End;
 
     if (Buffer != NULL)
         *Context = Buffer;
@@ -317,15 +317,15 @@ __strtok_r(
 
 static FORCEINLINE PWSTR
 __wcstok_r(
-    _In_opt_ PWSTR  Buffer,
-    _In_ PWSTR      Delimiter,
+    _In_opt_ PWSTR      Buffer,
+    _In_ PWSTR          Delimiter,
     _When_(Buffer != NULL, _Outptr_)
     _When_(Buffer == NULL, _Inout_)
-    PWSTR           *Context
+    PWSTR               *Context
     )
 {
-    PWSTR           Token;
-    PWSTR           End;
+    PWSTR               Token;
+    PWSTR               End;
 
     if (Buffer != NULL)
         *Context = Buffer;
-- 
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®.