|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 11/18] Annotate conditional output parameters with _Success_
Some functions that return a success flag only write their output
parameters on success. Annotate them with _Success_ so that code analysis
does not assume the outputs are valid on failure.
Also fix annotations found on the way: the HW_FIND_ADAPTER Again
parameter is _In_ in storport.h, BufferGet's Pfn is not a pointer, the
xenvbd Base64 __Decode writes up to three bytes, and PdoReadWrite reads
its Srb.
No functional change.
Signed-off-by: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
---
src/xencrsh/buffer.c | 3 ++-
src/xencrsh/buffer.h | 3 ++-
src/xencrsh/driver.c | 2 +-
src/xencrsh/pdo.c | 2 +-
src/xenvbd/adapter.c | 2 +-
src/xenvbd/base64.c | 7 ++++---
src/xenvbd/ring.c | 1 +
7 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/xencrsh/buffer.c b/src/xencrsh/buffer.c
index ef897f1..5a0c84d 100644
--- a/src/xencrsh/buffer.c
+++ b/src/xencrsh/buffer.c
@@ -98,10 +98,11 @@ BufferTerminate(
__Buffer.Next = 0;
}
+_Success_(return)
BOOLEAN
BufferGet(
_Out_ PULONG BufferId,
- _Outptr_ PFN_NUMBER *Pfn
+ _Out_ PFN_NUMBER *Pfn
)
{
ULONG BufId;
diff --git a/src/xencrsh/buffer.h b/src/xencrsh/buffer.h
index 39df51d..86294ac 100644
--- a/src/xencrsh/buffer.h
+++ b/src/xencrsh/buffer.h
@@ -45,10 +45,11 @@ extern VOID
BufferTerminate(
);
+_Success_(return)
extern BOOLEAN
BufferGet(
_Out_ PULONG BufferId,
- _Outptr_ PFN_NUMBER *Pfn
+ _Out_ PFN_NUMBER *Pfn
);
extern VOID
diff --git a/src/xencrsh/driver.c b/src/xencrsh/driver.c
index 70589b1..5874dea 100644
--- a/src/xencrsh/driver.c
+++ b/src/xencrsh/driver.c
@@ -198,7 +198,7 @@ HwFindAdapter(
_In_ PVOID BusInformation,
_In_ PSTR ArgumentString,
_Inout_ PPORT_CONFIGURATION_INFORMATION ConfigInfo,
- _Out_ PBOOLEAN Again
+ _In_ PBOOLEAN Again
)
{
UNREFERENCED_PARAMETER(Context);
diff --git a/src/xencrsh/pdo.c b/src/xencrsh/pdo.c
index d130fc8..b0c77bc 100644
--- a/src/xencrsh/pdo.c
+++ b/src/xencrsh/pdo.c
@@ -768,7 +768,7 @@ __ValidateSectors(
static BOOLEAN
PdoReadWrite(
_Inout_ PXENVBD_PDO Pdo,
- _Out_ PSCSI_REQUEST_BLOCK Srb
+ _Inout_ PSCSI_REQUEST_BLOCK Srb
)
{
NTSTATUS Status;
diff --git a/src/xenvbd/adapter.c b/src/xenvbd/adapter.c
index 5dafe07..5809af7 100644
--- a/src/xenvbd/adapter.c
+++ b/src/xenvbd/adapter.c
@@ -2103,7 +2103,7 @@ AdapterHwFindAdapter(
_In_ PVOID BusInformation,
_In_ PSTR ArgumentString,
_Inout_ PPORT_CONFIGURATION_INFORMATION ConfigInfo,
- _Out_ PBOOLEAN Again
+ _In_ PBOOLEAN Again
)
{
UNREFERENCED_PARAMETER(DevExt);
diff --git a/src/xenvbd/base64.c b/src/xenvbd/base64.c
index df398aa..7f20c40 100644
--- a/src/xenvbd/base64.c
+++ b/src/xenvbd/base64.c
@@ -72,11 +72,12 @@ __DecodeChar(
return 0xFF;
}
+_Success_(return >= 0)
static DECLSPEC_NOINLINE CHAR
__Decode(
- _Out_ PUCHAR Dst,
- _In_ PSTR Src,
- _In_ ULONG Left
+ _Out_writes_(3) PUCHAR Dst,
+ _In_reads_(Left) PSTR Src,
+ _In_ ULONG Left
)
{
UCHAR Values[4];
diff --git a/src/xenvbd/ring.c b/src/xenvbd/ring.c
index cd5093c..1d8df78 100644
--- a/src/xenvbd/ring.c
+++ b/src/xenvbd/ring.c
@@ -619,6 +619,7 @@ BlkifRingQueueRequests(
}
}
+_Success_(return)
static BOOLEAN
BlkifRingPrepareSegment(
_In_ PXENVBD_BLKIF_RING BlkifRing,
--
2.55.0.windows.5
--
Césaire Mounah | Vates Windows Guest Tools Engineer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |