diff options
| author | Michael Brown | 2025-07-15 17:51:05 +0200 |
|---|---|---|
| committer | Michael Brown | 2025-07-15 17:57:25 +0200 |
| commit | 8701863a17fab4726f1c76d7c123033d6e834019 (patch) | |
| tree | 3a33fea5ec1e2e32e4c5380c39267f24c43fce35 | |
| parent | [init] Show initialisation function names in debug messages (diff) | |
| download | ipxe-8701863a17fab4726f1c76d7c123033d6e834019.tar.gz ipxe-8701863a17fab4726f1c76d7c123033d6e834019.tar.xz ipxe-8701863a17fab4726f1c76d7c123033d6e834019.zip | |
[efi] Allow compiler to perform type checks on EFI_EVENT
As with EFI_HANDLE, the EFI headers define EFI_EVENT as a void
pointer, rendering EFI_EVENT compatible with a pointer to itself and
hence guaranteeing that pointer type bugs will be introduced.
Redefine EFI_EVENT as a pointer to an anonymous structure (as we
already do for EFI_HANDLE) to allow the compiler to perform type
checking as expected.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
| -rw-r--r-- | src/include/ipxe/efi/efi.h | 11 | ||||
| -rw-r--r-- | src/interface/efi/efi_console.c | 2 | ||||
| -rw-r--r-- | src/interface/efi/efi_snp.c | 2 |
3 files changed, 9 insertions, 6 deletions
diff --git a/src/include/ipxe/efi/efi.h b/src/include/ipxe/efi/efi.h index 33278abed..9dd26bff0 100644 --- a/src/include/ipxe/efi/efi.h +++ b/src/include/ipxe/efi/efi.h @@ -39,10 +39,10 @@ FILE_LICENCE ( GPL2_OR_LATER ); #define EFIAPI __attribute__((cdecl,regparm(0))) #endif -/* EFI headers define EFI_HANDLE as a void pointer, which renders type - * checking somewhat useless. Work around this bizarre sabotage - * attempt by redefining EFI_HANDLE as a pointer to an anonymous - * structure. +/* EFI headers define EFI_HANDLE and EFI_EVENT as void pointers, which + * renders type checking somewhat useless. Work around this bizarre + * sabotage attempt by redefining both as pointers to anonymous + * structures. * * EFI headers perform some ABI validation checks via _Static_assert() * that may fail when EFI headers are included on a non-EFI platform. @@ -50,13 +50,16 @@ FILE_LICENCE ( GPL2_OR_LATER ); * included. */ #define EFI_HANDLE STUPID_EFI_HANDLE +#define EFI_EVENT STUPID_EFI_EVENT #ifndef PLATFORM_efi #define _Static_assert(expr, msg) #endif #include <ipxe/efi/Uefi/UefiBaseType.h> #undef EFI_HANDLE +#undef EFI_EVENT #undef _Static_assert typedef struct {} *EFI_HANDLE; +typedef struct {} *EFI_EVENT; /* Include the top-level EFI header files */ #include <ipxe/efi/Uefi.h> diff --git a/src/interface/efi/efi_console.c b/src/interface/efi/efi_console.c index 4557671a0..c5a3f24ca 100644 --- a/src/interface/efi/efi_console.c +++ b/src/interface/efi/efi_console.c @@ -387,7 +387,7 @@ static int efi_iskey ( void ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_SIMPLE_TEXT_INPUT_PROTOCOL *conin = efi_systab->ConIn; EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *conin_ex = efi_conin_ex; - EFI_EVENT *event; + EFI_EVENT event; EFI_STATUS efirc; /* If we are mid-sequence, we are always ready */ diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c index b9706d5ab..88334c8d0 100644 --- a/src/interface/efi/efi_snp.c +++ b/src/interface/efi/efi_snp.c @@ -175,7 +175,7 @@ static void efi_snp_poll ( struct efi_snp_device *snpdev ) { while ( ( iobuf = netdev_rx_dequeue ( snpdev->netdev ) ) ) { list_add_tail ( &iobuf->list, &snpdev->rx ); snpdev->interrupts |= EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT; - bs->SignalEvent ( &snpdev->snp.WaitForPacket ); + bs->SignalEvent ( snpdev->snp.WaitForPacket ); } } |
