From 33de6b57a82a70a5b1e6991d0eb459f5c49578f9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 29 May 2018 17:12:39 +0200 Subject: [PATCH] efi: explicitly cast physical address to UINTN when converting to/from pointers UINTN is the integer type equalling the native ptr size. Let's fix the casting warnings described in #7788 by casting the the pointers and values to this type first. That way we cast integers to the right size first before turning them into pointers, and pointers are first covnerted to integers of the right size before converting them into integers. Not tested, since I lack i386 EFI systems, but I think this is simple enough to be correct event without testing. Fixes: #7788 --- src/boot/efi/boot.c | 2 +- src/boot/efi/linux.c | 2 +- src/boot/efi/stub.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index cc8fe6b641d..72a946b1ad3 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -1676,7 +1676,7 @@ static EFI_STATUS image_start(EFI_HANDLE parent_image, const Config *config, con #if ENABLE_TPM /* Try to log any options to the TPM, especially to catch manually edited options */ err = tpm_log_event(SD_TPM_PCR, - (EFI_PHYSICAL_ADDRESS) loaded_image->LoadOptions, + (EFI_PHYSICAL_ADDRESS) (UINTN) loaded_image->LoadOptions, loaded_image->LoadOptionsSize, loaded_image->LoadOptions); if (EFI_ERROR(err)) { Print(L"Unable to add image options measurement: %r", err); diff --git a/src/boot/efi/linux.c b/src/boot/efi/linux.c index e8f7651324f..1f81f3e7712 100644 --- a/src/boot/efi/linux.c +++ b/src/boot/efi/linux.c @@ -128,7 +128,7 @@ EFI_STATUS linux_exec(EFI_HANDLE *image, if (EFI_ERROR(err)) return err; CopyMem((VOID *)(UINTN)addr, cmdline, cmdline_len); - ((CHAR8 *)addr)[cmdline_len] = 0; + ((CHAR8 *)(UINTN)addr)[cmdline_len] = 0; boot_setup->cmd_line_ptr = (UINT32)addr; } diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c index f368a673512..c107a07ee74 100644 --- a/src/boot/efi/stub.c +++ b/src/boot/efi/stub.c @@ -90,7 +90,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { #if ENABLE_TPM /* Try to log any options to the TPM, especially manually edited options */ err = tpm_log_event(SD_TPM_PCR, - (EFI_PHYSICAL_ADDRESS) loaded_image->LoadOptions, + (EFI_PHYSICAL_ADDRESS) (UINTN) loaded_image->LoadOptions, loaded_image->LoadOptionsSize, loaded_image->LoadOptions); if (EFI_ERROR(err)) { Print(L"Unable to add image options measurement: %r", err); -- 2.47.3