|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XENNET-SYNC] xennet: Sync common helper files with xenbus
Take assert.h, dbg_print.h and util.h from xenbus, bringing the
updated direction and buffer-size annotations.
Signed-off-by: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
---
src/xennet/assert.h | 18 ++++++------
src/xennet/dbg_print.h | 66 ++++++++++++++++++++++++++----------------
src/xennet/util.h | 36 +++++++++++------------
3 files changed, 68 insertions(+), 52 deletions(-)
diff --git a/src/xennet/assert.h b/src/xennet/assert.h
index ac25718..a858f67 100644
--- a/src/xennet/assert.h
+++ b/src/xennet/assert.h
@@ -154,13 +154,13 @@ __Bug(
static __inline BOOLEAN
_IsZeroMemory(
- _In_ PCSTR Caller,
- _In_ PCSTR Name,
- _In_ PVOID Buffer,
- _In_ ULONG Length
+ _In_ PCSTR Caller,
+ _In_ PCSTR Name,
+ _In_reads_bytes_(Length) PVOID Buffer,
+ _In_ ULONG Length
)
{
- ULONG Offset;
+ ULONG Offset;
Offset = 0;
while (Offset < Length) {
@@ -178,10 +178,10 @@ _IsZeroMemory(
static __inline BOOLEAN
_IsZeroMemory(
- _In_ PCSTR Caller,
- _In_ PCSTR Name,
- _In_ PVOID Buffer,
- _In_ ULONG Length
+ _In_ PCSTR Caller,
+ _In_ PCSTR Name,
+ _In_reads_bytes_(Length) PVOID Buffer,
+ _In_ ULONG Length
)
{
UNREFERENCED_PARAMETER(Caller);
diff --git a/src/xennet/dbg_print.h b/src/xennet/dbg_print.h
index 9c2acdf..86a0296 100644
--- a/src/xennet/dbg_print.h
+++ b/src/xennet/dbg_print.h
@@ -1,32 +1,32 @@
/* Copyright (c) Xen Project.
* Copyright (c) Cloud Software Group, Inc.
* All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
* that the following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
* following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer in the documentation and/or other
* materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
@@ -36,12 +36,12 @@
#include <ntddk.h>
#include <stdarg.h>
-#pragma warning(disable:4127) // conditional expression is constant
-
#define stringify_literal(_text) #_text
#define stringify(_text) stringify_literal(_text)
#define __MODULE__ stringify(PROJECT)
+#pragma warning(disable:4127) // conditional expression is constant
+
static __inline VOID
__Error(
_In_ PCSTR Prefix,
@@ -138,4 +138,20 @@ __Info(
#define Info(...) \
__Info(__MODULE__ "|" __FUNCTION__ ": ", __VA_ARGS__)
+#define DBG_PRINT_ENABLE_FILTER(_Id, _Level) \
+ do { \
+ DbgSetDebugFilterState((_Id), (_Level), TRUE); \
+ } while (FALSE)
+
+static __inline VOID
+__DbgPrintEnable(
+ VOID
+ )
+{
+ DBG_PRINT_ENABLE_FILTER(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL);
+ DBG_PRINT_ENABLE_FILTER(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL);
+ DBG_PRINT_ENABLE_FILTER(DPFLTR_IHVDRIVER_ID, DPFLTR_TRACE_LEVEL);
+ DBG_PRINT_ENABLE_FILTER(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL);
+}
+
#endif // _XENNET_DBG_PRINT_H
diff --git a/src/xennet/util.h b/src/xennet/util.h
index 9709a10..db40d4f 100644
--- a/src/xennet/util.h
+++ b/src/xennet/util.h
@@ -113,12 +113,12 @@ __CpuId(
static FORCEINLINE LONG
__InterlockedAdd(
- _In_ LONG *Value,
- _In_ LONG Delta
+ _Inout_ LONG *Value,
+ _In_ LONG Delta
)
{
- LONG New;
- LONG Old;
+ LONG New;
+ LONG Old;
do {
Old = *Value;
@@ -130,12 +130,12 @@ __InterlockedAdd(
static FORCEINLINE LONG
__InterlockedSubtract(
- _In_ LONG *Value,
- _In_ LONG Delta
+ _Inout_ LONG *Value,
+ _In_ LONG Delta
)
{
- LONG New;
- LONG Old;
+ LONG New;
+ LONG Old;
do {
Old = *Value;
@@ -281,15 +281,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;
@@ -321,15 +321,15 @@ __strtok_r(
static FORCEINLINE PWSTR
__wcstok_r(
- _In_opt_ PWSTR Buffer,
- _In_ PWSTR Delimiter,
+ _Inout_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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |