Fix GCC 12 dangling-pointer warning

We're storing a persistent pointer to an ephemeral local variable
which technically is a dangling pointer and the compiler is correct.
However, since we never indirect the pointer, this is a safe
operation and we can suppress the warning.

Also, some C run-times (like MUSL) aren't including <stdint.h>
indirectly so we must include it explicitly or we won't have the
type definition for uintptr_t.

Fixes issue #867.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
This commit is contained in:
Philip Prindeville 2023-04-12 10:18:20 -06:00
parent 1631c7f3e9
commit aea0a5cfce
2 changed files with 6 additions and 0 deletions

View File

@ -185,7 +185,12 @@ AcpiUtInitStackPtrTrace (
ACPI_SIZE CurrentSp;
#pragma GCC diagnostic push
#if defined(__GNUC__) && __GNUC__ >= 12
#pragma GCC diagnostic ignored "-Wdangling-pointer="
#endif
AcpiGbl_EntryStackPointer = &CurrentSp;
#pragma GCC diagnostic pop
}

View File

@ -312,6 +312,7 @@
#ifdef ACPI_USE_STANDARD_HEADERS
#include <stddef.h>
#include <unistd.h>
#include <stdint.h>
#define ACPI_OFFSET(d, f) offsetof(d, f)
#endif