https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3fb5957de14da885a1632…
commit 3fb5957de14da885a16324fca028d9f0ea7fdf37
Author: Serge Gautherie <32623169+SergeGautherie(a)users.noreply.github.com>
AuthorDate: Mon Nov 13 20:55:48 2023 +0100
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Nov 13 20:55:48 2023 +0100
[NTOS:EX][CSRSRV][WIN32K] Make a few #define more explicit/strict (#5907)
- Add parentheses around macro parameters.
- Add casts on return value for the Interlocked*UL ("Unsigned Long")
macros.
---
ntoskrnl/include/internal/ex.h | 16 ++++++++--------
subsystems/csr/csrsrv/srv.h | 8 ++++----
win32ss/pch.h | 9 +++++----
3 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/ntoskrnl/include/internal/ex.h b/ntoskrnl/include/internal/ex.h
index f80cc7f8efd..50dde0cbfc8 100644
--- a/ntoskrnl/include/internal/ex.h
+++ b/ntoskrnl/include/internal/ex.h
@@ -79,9 +79,9 @@ VOID NTAPI ExpDebuggerWorker(IN PVOID Context);
#define HANDLE_LOW_BITS (PAGE_SHIFT - 3)
#define HANDLE_HIGH_BITS (PAGE_SHIFT - 2)
#endif
-#define HANDLE_TAG_BITS (2)
-#define HANDLE_INDEX_BITS (HANDLE_LOW_BITS + 2*HANDLE_HIGH_BITS)
-#define KERNEL_FLAG_BITS (sizeof(PVOID)*8 - HANDLE_INDEX_BITS - HANDLE_TAG_BITS)
+#define HANDLE_TAG_BITS 2
+#define HANDLE_INDEX_BITS (HANDLE_LOW_BITS + 2 * HANDLE_HIGH_BITS)
+#define KERNEL_FLAG_BITS (sizeof(ULONG_PTR) * 8 - HANDLE_INDEX_BITS -
HANDLE_TAG_BITS)
typedef union _EXHANDLE
{
@@ -160,9 +160,9 @@ typedef struct _HARDERROR_USER_PARAMETERS
#define MAX_MID_INDEX (MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
#define MAX_HIGH_INDEX (MID_LEVEL_ENTRIES * MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
-#define ExpChangeRundown(x, y, z)
(ULONG_PTR)InterlockedCompareExchangePointer(&x->Ptr, (PVOID)y, (PVOID)z)
-#define ExpChangePushlock(x, y, z) InterlockedCompareExchangePointer((PVOID*)x,
(PVOID)y, (PVOID)z)
-#define ExpSetRundown(x, y) InterlockedExchangePointer(&x->Ptr, (PVOID)y)
+#define ExpChangeRundown(x, y, z)
(ULONG_PTR)InterlockedCompareExchangePointer(&(x)->Ptr, (PVOID)(y), (PVOID)(z))
+#define ExpChangePushlock(x, y, z) InterlockedCompareExchangePointer((PVOID*)(x),
(PVOID)(y), (PVOID)(z))
+#define ExpSetRundown(x, y) InterlockedExchangePointer(&(x)->Ptr,
(PVOID)(y))
NTSTATUS
NTAPI
@@ -1541,10 +1541,10 @@ XIPInit(
#ifdef _WIN64
#define InterlockedExchangeSizeT(Target, Value) \
- (SIZE_T)InterlockedExchange64((PLONG64)Target, (LONG64)Value)
+ (SIZE_T)InterlockedExchange64((PLONG64)(Target), (LONG64)(Value))
#else
#define InterlockedExchangeSizeT(Target, Value) \
- (SIZE_T)InterlockedExchange((PLONG)Target, (LONG)Value)
+ (SIZE_T)InterlockedExchange((PLONG)(Target), (LONG)(Value))
#endif
#define ExfInterlockedCompareExchange64UL(Destination, Exchange, Comperand) \
diff --git a/subsystems/csr/csrsrv/srv.h b/subsystems/csr/csrsrv/srv.h
index d99c9633479..69ff83adbab 100644
--- a/subsystems/csr/csrsrv/srv.h
+++ b/subsystems/csr/csrsrv/srv.h
@@ -48,9 +48,9 @@
#define CSR_PORT_NAME L"ApiPort"
#define UNICODE_PATH_SEP L"\\"
-#define ROUND_UP(n, align) ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
-#define ROUND_DOWN(n, align) (((ULONG)n) & ~((align) - 1l))
-#define InterlockedIncrementUL(Value) _InterlockedIncrement((PLONG)Value)
-#define InterlockedDecrementUL(Value) _InterlockedDecrement((PLONG)Value)
+#define ROUND_UP(n, align) ROUND_DOWN(((ULONG)(n)) + (align) - 1, (align))
+#define ROUND_DOWN(n, align) (((ULONG)(n)) & ~((align) - 1l))
+#define InterlockedIncrementUL(Value) (ULONG)_InterlockedIncrement((PLONG)(Value))
+#define InterlockedDecrementUL(Value) (ULONG)_InterlockedDecrement((PLONG)(Value))
#endif /* _SRV_H */
diff --git a/win32ss/pch.h b/win32ss/pch.h
index 31bf7246d8b..d72708658f0 100644
--- a/win32ss/pch.h
+++ b/win32ss/pch.h
@@ -1,5 +1,3 @@
-#ifndef __W32K_H
-#define __W32K_H
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Win32k subsystem
@@ -8,6 +6,9 @@
* PROGRAMMER: Alex Ionescu (alex(a)relsoft.net)
*/
+#ifndef __W32K_H
+#define __W32K_H
+
/* INCLUDES ******************************************************************/
#define _NO_COM
@@ -103,8 +104,8 @@ extern "C" {
#include <ft2build.h>
#include FT_FREETYPE_H
-#define InterlockedIncrementUL(Value) InterlockedIncrement((PLONG)Value)
-#define InterlockedDecrementUL(Value) InterlockedDecrement((PLONG)Value)
+#define InterlockedIncrementUL(Value) (ULONG)InterlockedIncrement((PLONG)(Value))
+#define InterlockedDecrementUL(Value) (ULONG)InterlockedDecrement((PLONG)(Value))
/* Internal Win32K header */
#include "win32kp.h"