Building 32bit boards with the TCG2 protocol enabled leads to a build
warning due to a missing conversion.

    lib/efi_loader/efi_tcg2.c: In function 'tcg2_measure_pe_image':
    lib/efi_loader/efi_tcg2.c:856:47: error: cast from pointer to
    integer of different size [-Werror=pointer-to-int-cast]
      856 |  image_load_event->image_location_in_memory = 
(efi_physical_addr_t)efi;
          |                                               ^
    lib/efi_loader/efi_tcg2.c: In function 'efi_tcg2_hash_log_extend_event':
    lib/efi_loader/efi_tcg2.c:947:22: error: cast to pointer from integer
    of different size [-Werror=int-to-pointer-cast]
      947 |   ret = efi_check_pe((void *)data_to_hash, data_to_hash_len,
          |                      ^
    lib/efi_loader/efi_tcg2.c:953:28: error: cast to pointer from
    integer of different size [-Werror=int-to-pointer-cast]
      953 |   ret = tcg2_hash_pe_image((void *)data_to_hash, data_to_hash_len,
          |                            ^

Signed-off-by: Masahisa Kojima <masahisa.koj...@linaro.org>
---
 lib/efi_loader/efi_tcg2.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
index 3dd417aa27..47bc371477 100644
--- a/lib/efi_loader/efi_tcg2.c
+++ b/lib/efi_loader/efi_tcg2.c
@@ -853,7 +853,7 @@ efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size,
        if (!image_load_event)
                return EFI_OUT_OF_RESOURCES;
 
-       image_load_event->image_location_in_memory = (efi_physical_addr_t)efi;
+       image_load_event->image_location_in_memory = (uintptr_t)efi;
        image_load_event->image_length_in_memory = efi_size;
        image_load_event->length_of_device_path = device_path_length;
 
@@ -944,14 +944,14 @@ efi_tcg2_hash_log_extend_event(struct efi_tcg2_protocol 
*this, u64 flags,
        if (flags & PE_COFF_IMAGE) {
                IMAGE_NT_HEADERS32 *nt;
 
-               ret = efi_check_pe((void *)data_to_hash, data_to_hash_len,
-                                  (void **)&nt);
+               ret = efi_check_pe((void *)(uintptr_t)data_to_hash,
+                                  data_to_hash_len, (void **)&nt);
                if (ret != EFI_SUCCESS) {
                        log_err("Not a valid PE-COFF file\n");
                        goto out;
                }
-               ret = tcg2_hash_pe_image((void *)data_to_hash, data_to_hash_len,
-                                        &digest_list);
+               ret = tcg2_hash_pe_image((void *)(uintptr_t)data_to_hash,
+                                        data_to_hash_len, &digest_list);
        } else {
                ret = tcg2_create_digest((u8 *)(uintptr_t)data_to_hash,
                                         data_to_hash_len, &digest_list);
-- 
2.17.1

Reply via email to