[PATCH 1/2] kernel-stub: Avoid warnings when converting buffer addresses to pointers

3 views
Skip to first unread message

Jan Kiszka

unread,
Aug 10, 2023, 4:01:15 AM8/10/23
to efibootguard-dev
From: Jan Kiszka <jan.k...@siemens.com>

On 32-bit systems, we get "cast to pointer from integer of different
size" warnings. Silence then which we can safely do because the
fdt_buffer will not exceed 32 bits, being provided by AllocatePages().

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
kernel-stub/fdt.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/kernel-stub/fdt.c b/kernel-stub/fdt.c
index 68315f9..e2174af 100644
--- a/kernel-stub/fdt.c
+++ b/kernel-stub/fdt.c
@@ -166,7 +166,8 @@ static EFI_STATUS clone_fdt(const VOID *fdt, UINTN size,
error(L"Error allocating device tree buffer", status);
return status;
}
- CopyMem((VOID *)*fdt_buffer, fdt, BE32_TO_HOST(header->TotalSize));
+ CopyMem((VOID *)(uintptr_t)*fdt_buffer, fdt,
+ BE32_TO_HOST(header->TotalSize));
return EFI_SUCCESS;
}

@@ -203,7 +204,8 @@ EFI_STATUS replace_fdt(const VOID *fdt)
return status;
}

- status = protocol->Fixup(protocol, (VOID *)fdt_buffer, &size,
+ status = protocol->Fixup(protocol,
+ (VOID *)(uintptr_t)fdt_buffer, &size,
EFI_DT_APPLY_FIXUPS |
EFI_DT_RESERVE_MEMORY);
if (EFI_ERROR(status)) {
@@ -214,7 +216,7 @@ EFI_STATUS replace_fdt(const VOID *fdt)
}

status = BS->InstallConfigurationTable(&EfiDtbTableGuid,
- (VOID *)fdt_buffer);
+ (VOID *)(uintptr_t)fdt_buffer);
if (EFI_ERROR(status)) {
(VOID) BS->FreePages(fdt_buffer, SIZE_IN_PAGES(size));
error(L"Failed to install alternative device tree", status);
--
2.35.3
Reply all
Reply to author
Forward
0 new messages