diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index e314d319614..2cfcda7c622 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -144,22 +144,16 @@ EFI_STATUS open_directory(EFI_FILE *root_dir, const char16_t *path, EFI_FILE **r /* Conversion between EFI_PHYSICAL_ADDRESS and pointers is not obvious. The former is always 64bit, even on * 32bit archs. And gcc complains if we cast a pointer to an integer of a different size. Hence let's do the - * conversion indirectly: first into UINTN (which is defined by UEFI to have the same size as a pointer), and - * then extended to EFI_PHYSICAL_ADDRESS. */ + * conversion indirectly: first into uintptr_t and then extended to EFI_PHYSICAL_ADDRESS. */ static inline EFI_PHYSICAL_ADDRESS POINTER_TO_PHYSICAL_ADDRESS(const void *p) { - return (EFI_PHYSICAL_ADDRESS) (UINTN) p; + return (EFI_PHYSICAL_ADDRESS) (uintptr_t) p; } static inline void *PHYSICAL_ADDRESS_TO_POINTER(EFI_PHYSICAL_ADDRESS addr) { -#if __SIZEOF_POINTER__ == 4 /* On 32bit systems the address might not be convertible (as pointers are 32bit but * EFI_PHYSICAL_ADDRESS 64bit) */ - assert(addr <= UINT32_MAX); -#elif __SIZEOF_POINTER__ != 8 - #error "Unexpected pointer size" -#endif - - return (void*) (UINTN) addr; + assert(addr <= UINTPTR_MAX); + return (void *) (uintptr_t) addr; } uint64_t get_os_indications_supported(void);