[U-Boot] [PATCH 02/17] efi_loader: parameters of CopyMem and SetMem

Heinrich Schuchardt xypron.glpk at gmx.de
Sun Sep 24 19:57:01 UTC 2017


The UEFI spec defines the length parameters of CopyMem and SetMem
as UINTN. We should size_t here.

The source buffer of CopyMem should be marked as const.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 include/efi_api.h             |  7 +++----
 lib/efi_loader/efi_boottime.c | 10 +++++-----
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index c3b9032a48..0b1a383e61 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -156,10 +156,9 @@ struct efi_boot_services {
 			void *handle, ...);
 	efi_status_t (EFIAPI *calculate_crc32)(void *data,
 			unsigned long data_size, uint32_t *crc32);
-	void (EFIAPI *copy_mem)(void *destination, void *source,
-			unsigned long length);
-	void (EFIAPI *set_mem)(void *buffer, unsigned long size,
-			uint8_t value);
+	void (EFIAPI *copy_mem)(void *destination, const void *source,
+			size_t length);
+	void (EFIAPI *set_mem)(void *buffer, size_t size, uint8_t value);
 	void *create_event_ex;
 };
 
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 2c2620a46d..22e6e6c569 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1877,10 +1877,10 @@ static efi_status_t EFIAPI efi_calculate_crc32(void *data,
  * @source		source of the copy operation
  * @length		number of bytes to copy
  */
-static void EFIAPI efi_copy_mem(void *destination, void *source,
-				unsigned long length)
+static void EFIAPI efi_copy_mem(void *destination, const void *source,
+				size_t length)
 {
-	EFI_ENTRY("%p, %p, %ld", destination, source, length);
+	EFI_ENTRY("%p, %p, %ld", destination, source, (unsigned long)length);
 	memcpy(destination, source, length);
 	EFI_EXIT(EFI_SUCCESS);
 }
@@ -1896,9 +1896,9 @@ static void EFIAPI efi_copy_mem(void *destination, void *source,
  * @size		size of buffer in bytes
  * @value		byte to copy to the buffer
  */
-static void EFIAPI efi_set_mem(void *buffer, unsigned long size, uint8_t value)
+static void EFIAPI efi_set_mem(void *buffer, size_t size, uint8_t value)
 {
-	EFI_ENTRY("%p, %ld, 0x%x", buffer, size, value);
+	EFI_ENTRY("%p, %ld, 0x%x", buffer, (unsigned long)size, value);
 	memset(buffer, value, size);
 	EFI_EXIT(EFI_SUCCESS);
 }
-- 
2.14.1



More information about the U-Boot mailing list