From 0f814783ef9ed3a50e15cab08579218ec45b4640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sat, 21 May 2022 12:15:16 +0200 Subject: ACPI_CAST_PTR: cast through "void *" Not all pointer are castable to integers directly and ACPI_UINTPTR_T is not guaranteed to be "void *". --- source/include/actypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/include/actypes.h b/source/include/actypes.h index fff6c1659..b7f22172f 100644 --- a/source/include/actypes.h +++ b/source/include/actypes.h @@ -649,7 +649,7 @@ typedef UINT64 ACPI_INTEGER; /* Pointer manipulation */ -#define ACPI_CAST_PTR(t, p) ((t *) (ACPI_UINTPTR_T) (p)) +#define ACPI_CAST_PTR(t, p) ((t *) (ACPI_UINTPTR_T) (void *) (p)) #define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (ACPI_UINTPTR_T) (p)) #define ACPI_ADD_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) + (ACPI_SIZE)(b))) #define ACPI_SUB_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) - (ACPI_SIZE)(b))) -- cgit v1.2.1 From 6b7a78c41c04772a30923c8c0ba71770d55ac815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sat, 21 May 2022 12:17:14 +0200 Subject: Linux non-kernel: Use use uintptr_t for ACPI_UINTPTR_T --- source/include/platform/aclinux.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/include/platform/aclinux.h b/source/include/platform/aclinux.h index 1c55c659f..a4f7d27bf 100644 --- a/source/include/platform/aclinux.h +++ b/source/include/platform/aclinux.h @@ -168,6 +168,8 @@ #define ACPI_USE_DO_WHILE_0 #define ACPI_IGNORE_PACKAGE_RESOLUTION_ERRORS +#define ACPI_UINTPTR_T uintptr_t + #ifdef __KERNEL__ @@ -252,8 +254,6 @@ #define ACPI_SPINLOCK spinlock_t * #define ACPI_CPU_FLAGS unsigned long -#define ACPI_UINTPTR_T uintptr_t - #define ACPI_TO_INTEGER(p) ((uintptr_t)(p)) #define ACPI_OFFSET(d, f) offsetof(d, f) @@ -311,6 +311,7 @@ #ifdef ACPI_USE_STANDARD_HEADERS #include +#include #endif /* Define/disable kernel-specific declarators */ -- cgit v1.2.1 From 2185f7d5d7a5650dbcb6a05e9de41f340cd3b865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sat, 21 May 2022 12:17:58 +0200 Subject: debug: use UINT_PTR_T to store stack boundaries GCC12 complains about storing invalid pointers, store them as integers instead. obj/acpiexec ../../../source/components/utilities/utdebug.c ../../../source/components/utilities/utdebug.c: In function 'AcpiUtInitStackPtrTrace': ../../../source/components/utilities/utdebug.c:188:31: error: storing the address of local variable 'CurrentSp' in 'AcpiGbl_EntryStackPointer' [-Werror=dangling-pointer=] 188 | AcpiGbl_EntryStackPointer = &CurrentSp; | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ ../../../source/components/utilities/utdebug.c:185:29: note: 'CurrentSp' declared here 185 | ACPI_SIZE CurrentSp; | ^~~~~~~~~ Fixes #771 --- source/components/debugger/dbstats.c | 4 ++-- source/components/utilities/utdebug.c | 6 +++--- source/components/utilities/utinit.c | 2 +- source/include/acglobal.h | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/components/debugger/dbstats.c b/source/components/debugger/dbstats.c index 30a686dc6..3d31378f5 100644 --- a/source/components/debugger/dbstats.c +++ b/source/components/debugger/dbstats.c @@ -647,8 +647,8 @@ AcpiDbDisplayStatistics ( AcpiGbl_EntryStackPointer, AcpiGbl_LowestStackPointer); AcpiOsPrintf ("\nSubsystem Stack Usage:\n\n"); - AcpiOsPrintf ("Entry Stack Pointer %p\n", AcpiGbl_EntryStackPointer); - AcpiOsPrintf ("Lowest Stack Pointer %p\n", AcpiGbl_LowestStackPointer); + AcpiOsPrintf ("Entry Stack Pointer %p\n", ACPI_TO_POINTER(AcpiGbl_EntryStackPointer)); + AcpiOsPrintf ("Lowest Stack Pointer %p\n", ACPI_TO_POINTER(AcpiGbl_LowestStackPointer)); AcpiOsPrintf ("Stack Use %X (%u)\n", Temp, Temp); AcpiOsPrintf ("Deepest Procedure Nesting %u\n", AcpiGbl_DeepestNesting); #endif diff --git a/source/components/utilities/utdebug.c b/source/components/utilities/utdebug.c index f789e686d..baaf6a691 100644 --- a/source/components/utilities/utdebug.c +++ b/source/components/utilities/utdebug.c @@ -185,7 +185,7 @@ AcpiUtInitStackPtrTrace ( ACPI_SIZE CurrentSp; - AcpiGbl_EntryStackPointer = &CurrentSp; + AcpiGbl_EntryStackPointer = ACPI_TO_INTEGER(&CurrentSp); } @@ -208,9 +208,9 @@ AcpiUtTrackStackPtr ( ACPI_SIZE CurrentSp; - if (&CurrentSp < AcpiGbl_LowestStackPointer) + if (ACPI_TO_INTEGER(&CurrentSp) < AcpiGbl_LowestStackPointer) { - AcpiGbl_LowestStackPointer = &CurrentSp; + AcpiGbl_LowestStackPointer = ACPI_TO_INTEGER(&CurrentSp); } if (AcpiGbl_NestingLevel > AcpiGbl_DeepestNesting) diff --git a/source/components/utilities/utinit.c b/source/components/utilities/utinit.c index 0f2cf4890..e3774bac3 100644 --- a/source/components/utilities/utinit.c +++ b/source/components/utilities/utinit.c @@ -359,7 +359,7 @@ AcpiUtInitGlobals ( #endif #ifdef ACPI_DEBUG_OUTPUT - AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX); + AcpiGbl_LowestStackPointer = ACPI_SIZE_MAX; #endif #ifdef ACPI_DBG_TRACK_ALLOCATIONS diff --git a/source/include/acglobal.h b/source/include/acglobal.h index b8831b467..eddecc9f8 100644 --- a/source/include/acglobal.h +++ b/source/include/acglobal.h @@ -331,8 +331,8 @@ extern const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames [NUM_PREDEFINED_ ACPI_GLOBAL (UINT32, AcpiGbl_CurrentNodeCount); ACPI_GLOBAL (UINT32, AcpiGbl_CurrentNodeSize); ACPI_GLOBAL (UINT32, AcpiGbl_MaxConcurrentNodeCount); -ACPI_GLOBAL (ACPI_SIZE *, AcpiGbl_EntryStackPointer); -ACPI_GLOBAL (ACPI_SIZE *, AcpiGbl_LowestStackPointer); +ACPI_GLOBAL (ACPI_UINTPTR_T, AcpiGbl_EntryStackPointer); +ACPI_GLOBAL (ACPI_UINTPTR_T, AcpiGbl_LowestStackPointer); ACPI_GLOBAL (UINT32, AcpiGbl_DeepestNesting); ACPI_INIT_GLOBAL (UINT32, AcpiGbl_NestingLevel, 0); #endif -- cgit v1.2.1