[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.
This commit is contained in:
Serge Gautherie 2023-11-13 20:55:48 +01:00 committed by GitHub
parent e07dbf782c
commit 3fb5957de1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 16 deletions

View file

@ -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) \

View file

@ -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 */

View file

@ -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@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"