From: Jan Janssen Date: Tue, 12 Jul 2022 07:43:13 +0000 (+0200) Subject: boot: Use uintptr_t when converting EFI_PHYSICAL_ADDRESS X-Git-Tag: v252-rc1~675^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34938db5b30558d9bcef6ac8518901c7a83638ee;p=thirdparty%2Fsystemd.git boot: Use uintptr_t when converting EFI_PHYSICAL_ADDRESS uintptr_t is the more appropriate type when casting to/from pointers. --- 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);