Fix compiler warnings for 32-bit ARM
cover Fix compiler warnings for 32-bit ARM
These were noticed when building sandbox on a Raspberry Pi 400, which uses 32-bit linux.
To make this work, I enabled CONFIG_HOST_32BIT in 'make menuconfig'. It would be nice if that were automatic, since we have the logic already in arch/sandbox/config.mk
There are still many errors of the form:
/usr/bin/ld: warning: arch/sandbox/cpu/start.o uses 2-byte wchar_t yet the
output is to use 4-byte wchar_t; use of wchar_t values across objects may fail
I am not sure how to fix those, but they are not fatal (sandbox still runs).
Simon Glass (7):
mkeficapsule: Correct printf() strings
efi: Fix compiler warnings
pci: swap_case: Allow compilation on 32-bit machines
tpm: Correct warning on 32-bit build
test: acpi: Fix warnings on 32-bit build
doc: sandbox: Fix up dependencies
doc: sandbox: Update instructions on quitting
cmd/efidebug.c | 2 +- doc/arch/sandbox.rst | 11 ++++++----- drivers/misc/swap_case.c | 13 +++++++++++-- drivers/tpm/tpm2_tis_sandbox.c | 2 +- lib/efi_loader/efi_capsule.c | 4 ++-- lib/efi_loader/efi_firmware.c | 4 ++-- test/dm/acpi.c | 12 ++++++------ tools/mkeficapsule.c | 14 +++++++------- 8 files changed, 36 insertions(+), 26 deletions(-)
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
PATCH 1/7 mkeficapsule: Correct printf() strings
Use %z when printing size_t values. This avoids errors on 32-bit machines.
---
tools/mkeficapsule.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
tools/mkeficapsule.c +7 -7
@@ -278,7 +278,7 @@ static int create_fwbin(char *path, char *bin, efi_guid_t *guid, } data =malloc (bin_stat.st_size);if (!data) { -printf ("cannot allocate memory: %lx\n" , bin_stat.st_size); +printf ("cannot allocate memory: %lx\n" , (ulong )bin_stat.st_size); goto err_1; } f =fopen (path,"w" );
@@ -297,7 +297,7 @@ static int create_fwbin(char *path, char *bin, efi_guid_t *guid, size =fwrite (&header,1 ,sizeof (header), f);if (size <sizeof (header)) { -printf ("write failed (%lx)\n" , size); +printf ("write failed (%zx)\n" , size); goto err_3; }
@@ -306,13 +306,13 @@ static int create_fwbin(char *path, char *bin, efi_guid_t *guid, capsule.payload_item_count =1 ; size =fwrite (&capsule,1 ,sizeof (capsule), f);if (size < (sizeof (capsule))) { -printf ("write failed (%lx)\n" , size); +printf ("write failed (%zx)\n" , size); goto err_3; } offset =sizeof (capsule) +sizeof (u64); size =fwrite (&offset,1 ,sizeof (offset), f);if (size <sizeof (offset)) { -printf ("write failed (%lx)\n" , size); +printf ("write failed (%zx)\n" , size); goto err_3; }
@@ -329,17 +329,17 @@ static int create_fwbin(char *path, char *bin, efi_guid_t *guid, size =fwrite (&image,1 ,sizeof (image), f);if (size <sizeof (image)) { -printf ("write failed (%lx)\n" , size); +printf ("write failed (%zx)\n" , size); goto err_3; } size =fread (data,1 , bin_stat.st_size, g);if (size < bin_stat.st_size) { -printf ("read failed (%lx)\n" , size); +printf ("read failed (%zx)\n" , size); goto err_3; } size =fwrite (data,1 , bin_stat.st_size, f);if (size < bin_stat.st_size) { -printf ("write failed (%lx)\n" , size); +printf ("write failed (%zx)\n" , size); goto err_3; }
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
PATCH 1/7 mkeficapsule: Correct printf() strings
Quoted 14 lines · Simon Glass
Use %z when printing
size_tvalues. This avoids errors on 32-bit machines.Signed-off-by Simon Glass <[email protected]>---
tools/mkeficapsule.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)tools/mkeficapsule.c +0
-0
tools/mkeficapsule.c static int create_fwbin(char *path, char *bin, efi_guid_t *guid, · line 281
Quoted 5 lines
tools/mkeficapsule.c +1
-1@@ -278,7 +278,7 @@ static int create_fwbin(char *path, char *bin, efi_guid_t *guid, } data =malloc (bin_stat.st_size);if (!data) { -printf ("cannot allocate memory: %lx\n" , bin_stat.st_size); +printf ("cannot allocate memory: %lx\n" , (ulong )bin_stat.st_size);
Thanks for addressing the build problem.
bin_stat.st_size is of type off_t which may be u64 on 32bit systems.
We must check that bin_stat.st_size <= SIZE_MAX before calling malloc() otherwise the value may be truncated.
The capsule file will end up on a FAT file system which has a file size limit of 2^32-1. Typically the ESP has a size of 100 MiB. We should at least check that bin_stat.st_size <= 2^32-1.
Converting to size_t instead of ulong seems to be the natural choice for a parameter called size.
tools/mkeficapsule.c static int create_fwbin(char *path, char *bin, efi_guid_t *guid, · line 300
Quoted 9 lines
tools/mkeficapsule.c +1
-1goto err_1; } f =fopen (path,"w" );@@ -297,7 +297,7 @@ static int create_fwbin(char *path, char *bin, efi_guid_t *guid, size =fwrite (&header,1 ,sizeof (header), f);if (size <sizeof (header)) { -printf ("write failed (%lx)\n" , size); +printf ("write failed (%zx)\n" , size);
ok
tools/mkeficapsule.c static int create_fwbin(char *path, char *bin, efi_guid_t *guid, · line 309
Quoted 9 lines
tools/mkeficapsule.c +1
-1goto err_3; }@@ -306,13 +306,13 @@ static int create_fwbin(char *path, char *bin, efi_guid_t *guid, capsule.payload_item_count =1 ; size =fwrite (&capsule,1 ,sizeof (capsule), f);if (size < (sizeof (capsule))) { -printf ("write failed (%lx)\n" , size); +printf ("write failed (%zx)\n" , size);
ok
tools/mkeficapsule.c static int create_fwbin(char *path, char *bin, efi_guid_t *guid, · line 315
Quoted 7 lines
tools/mkeficapsule.c +1
-1goto err_3; } offset =sizeof (capsule) +sizeof (u64); size =fwrite (&offset,1 ,sizeof (offset), f);if (size <sizeof (offset)) { -printf ("write failed (%lx)\n" , size); +printf ("write failed (%zx)\n" , size);
ok
tools/mkeficapsule.c static int create_fwbin(char *path, char *bin, efi_guid_t *guid, · line 332
Quoted 9 lines
tools/mkeficapsule.c +1
-1goto err_3; }@@ -329,17 +329,17 @@ static int create_fwbin(char *path, char *bin, efi_guid_t *guid, size =fwrite (&image,1 ,sizeof (image), f);if (size <sizeof (image)) { -printf ("write failed (%lx)\n" , size); +printf ("write failed (%zx)\n" , size);
ok
tools/mkeficapsule.c static int create_fwbin(char *path, char *bin, efi_guid_t *guid, · line 337
Quoted 6 lines
tools/mkeficapsule.c +1
-1goto err_3; } size =fread (data,1 , bin_stat.st_size, g);if (size < bin_stat.st_size) { -printf ("read failed (%lx)\n" , size); +printf ("read failed (%zx)\n" , size);
ok
tools/mkeficapsule.c static int create_fwbin(char *path, char *bin, efi_guid_t *guid, · line 342
Quoted 6 lines
tools/mkeficapsule.c +1
-1goto err_3; } size =fwrite (data,1 , bin_stat.st_size, f);if (size < bin_stat.st_size) { -printf ("write failed (%lx)\n" , size); +printf ("write failed (%zx)\n" , size);
ok
Best regards
Heinrich
Quoted 4 lines
tools/mkeficapsule.c +0
-0goto err_3; }
PATCH 2/7 efi: Fix compiler warnings
In reply to Simon GlassThis occur when building on Raspberry Pi 400 (32-bit ARM). Fix them.
Examples:
cmd/efidebug.c: In function ?do_efi_capsule_update?:cmd/efidebug.c:75:49: warning: cast from pointer to integer of different
size [-Wpointer-to-int-cast]
ret = EFI_CALL(RT->update_capsule(&capsule, 1, (u64)NULL));
^
include/efi_loader.h:104:9: note: in definition of macro ?EFI_CALL?
typeof(exp) _r = exp; \
^~~
cmd/efidebug.c:75:49: warning: cast from pointer to integer of different
size [-Wpointer-to-int-cast]
ret = EFI_CALL(RT->update_capsule(&capsule, 1, (u64)NULL));
^
include/efi_loader.h:104:19: note: in definition of macro ?EFI_CALL?
typeof(exp) _r = exp; \
^~~In file included from include/common.h:20,
from lib/efi_loader/efi_capsule.c:9:lib/efi_loader/efi_capsule.c: In function ?efi_update_capsule?:include/efi_loader.h:83:8: warning: format ?%lu? expects argument of type
?long unsigned int?, but argument 10 has type ?size_t? {aka ?unsigned int?} [-Wformat=]
debug("%sEFI: Entry %s(" format ")\n", __efi_nesting_inc(), \
^~~~~~~~~~~~~~~~~~
include/linux/printk.h:37:21: note: in definition of macro ?pr_fmt?
#define pr_fmt(fmt) fmt
^~~include/log.h:229:2: note: in expansion of macro ?log?
log(LOG_CATEGORY, LOGL_DEBUG, fmt, ##args); \
^~~include/log.h:249:2: note: in expansion of macro ?debug_cond?
debug_cond(_DEBUG, fmt, ##args)
^~~~~~~~~~include/efi_loader.h:83:2: note: in expansion of macro ?debug?
debug("%sEFI: Entry %s(" format ")\n", __efi_nesting_inc(), \
^~~~~lib/efi_loader/efi_capsule.c:444:2: note: in expansion of macro ?EFI_ENTRY?
EFI_ENTRY("%p, %lu, %llu\n", capsule_header_array, capsule_count, ^~~~~~~~~lib/efi_loader/efi_capsule.c:444:19: note: format string is defined here
EFI_ENTRY("%p, %lu, %llu\n", capsule_header_array, capsule_count,
~~^
%u---
cmd/efidebug.c | 2 +- lib/efi_loader/efi_capsule.c | 4 ++-- lib/efi_loader/efi_firmware.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
cmd/efidebug.c +1 -1
@@ -72,7 +72,7 @@ static int do_efi_capsule_update(struct cmd_tbl *cmdtp, int flag, capsule->capsule_image_size); } - ret =EFI_CALL (RT ->update_capsule (&capsule,1 , (u64 )NULL )); + ret =EFI_CALL (RT ->update_capsule (&capsule,1 , (uintptr_t )NULL ));if (ret) {printf ("Cannot handle a capsule at %p" , capsule);return CMD_RET_FAILURE ;
lib/efi_loader/efi_capsule.c +2 -2
@@ -441,7 +441,7 @@ efi_status_t EFIAPI efi_update_capsule(unsigned int i;efi_status_t ret; -EFI_ENTRY ("%p, %lu, %llu\n" , capsule_header_array, capsule_count, +EFI_ENTRY ("%p, %zu, %llu\n" , capsule_header_array, capsule_count, scatter_gather_list);if (!capsule_count) {
@@ -501,7 +501,7 @@ efi_status_t EFIAPI efi_query_capsule_caps(unsigned int i;efi_status_t ret; -EFI_ENTRY ("%p, %lu, %p, %p\n" , capsule_header_array, capsule_count, +EFI_ENTRY ("%p, %zu, %p, %p\n" , capsule_header_array, capsule_count, maximum_capsule_size, reset_type);if (!maximum_capsule_size) {
lib/efi_loader/efi_firmware.c +2 -2
@@ -299,7 +299,7 @@ efi_status_t EFIAPI efi_firmware_fit_set_image( efi_status_t (*progress)(efi_uintn_t completion), u16 **abort_reason) { - EFI_ENTRY("%p %d %p %ld %p %p %p\n", this, image_index, image, + EFI_ENTRY("%p %d %p %zd %p %p %p\n", this, image_index, image, image_size, vendor_code, progress, abort_reason);if (!image || image_index !=1 )
@@ -414,7 +414,7 @@ efi_status_t EFIAPI efi_firmware_raw_set_image(efi_status_t status;efi_uintn_t capsule_payload_size; -EFI_ENTRY ("%p %d %p %ld %p %p %p\n" , this, image_index, image, +EFI_ENTRY ("%p %d %p %zd %p %p %p\n" , this, image_index, image, image_size, vendor_code, progress, abort_reason);if (!image)
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
PATCH 2/7 efi: Fix compiler warnings
Quoted 61 lines · Simon Glass
This occur when building on Raspberry Pi 400 (32-bit ARM). Fix them.
Examples:
cmd/efidebug.c: In function ?do_efi_capsule_update?:cmd/efidebug.c:75:49: warning: cast from pointer to integer of different
size [-Wpointer-to-int-cast]ret = EFI_CALL(RT->update_capsule(&capsule, 1, (u64)NULL)); ^ include/efi_loader.h:104:9: note: in definition of macro ?EFI_CALL? typeof(exp) _r = exp; \ ^~~ cmd/efidebug.c:75:49: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] ret = EFI_CALL(RT->update_capsule(&capsule, 1, (u64)NULL)); ^ include/efi_loader.h:104:19: note: in definition of macro ?EFI_CALL? typeof(exp) _r = exp; \ ^~~In file included from
include/common.h:20,
fromlib/efi_loader/efi_capsule.c:9:lib/efi_loader/efi_capsule.c: In function ?efi_update_capsule?:include/efi_loader.h:83:8: warning: format ?%lu? expects argument of type
?long unsigned int?, but argument 10 has type ?size_t? {aka ?unsigned int?} [-Wformat=]debug("%sEFI: Entry %s(" format ")\n", __efi_nesting_inc(), \ ^~~~~~~~~~~~~~~~~~ include/linux/printk.h:37:21: note: in definition of macro ?pr_fmt? #define pr_fmt(fmt) fmt ^~~ include/log.h:229:2: note: in expansion of macro ?log? log(LOG_CATEGORY, LOGL_DEBUG, fmt, ##args); \ ^~~
include/log.h:249:2: note: in expansion of macro ?debug_cond?
debug_cond(_DEBUG, fmt, ##args)
^~~~~~~~~~include/efi_loader.h:83:2: note: in expansion of macro ?debug?debug("%sEFI: Entry %s(" format ")\n", __efi_nesting_inc(), \ ^~~~~
lib/efi_loader/efi_capsule.c:444:2: note: in expansion of macro ?EFI_ENTRY?
EFI_ENTRY("%p, %lu, %llu\n",capsule_header_array,capsule_count, ^~~~~~~~~lib/efi_loader/efi_capsule.c:444:19: note: format string is defined here
EFI_ENTRY("%p, %lu, %llu\n",capsule_header_array,capsule_count,~~^ %uSigned-off-by Simon Glass <[email protected]>---
cmd/efidebug.c | 2 +- lib/efi_loader/efi_capsule.c | 4 ++-- lib/efi_loader/efi_firmware.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)cmd/efidebug.c +0
-0
cmd/efidebug.c static int do_efi_capsule_update(struct cmd_tbl *cmdtp, int flag, · line 75
Quoted 5 lines
cmd/efidebug.c +1
-1@@ -72,7 +72,7 @@ static int do_efi_capsule_update(struct cmd_tbl *cmdtp, int flag, capsule->capsule_image_size); } - ret =EFI_CALL (RT ->update_capsule (&capsule,1 , (u64 )NULL )); + ret =EFI_CALL (RT ->update_capsule (&capsule,1 , (uintptr_t )NULL ));
Thanks for addressing this issue.
According to the UEFI specification the third parameter is of type EFI_PHYSICAL_ADDRESS i.e. u64.
Simply use 0 instead of (uintptr_t)NULL.
Quoted 8 lines
cmd/efidebug.c +0
-0if (ret) {printf ("Cannot handle a capsule at %p" , capsule);return CMD_RET_FAILURE ;lib/efi_loader/efi_capsule.c +0
-0
lib/efi_loader/efi_capsule.c efi_status_t EFIAPI efi_update_capsule( · line 445
Quoted 6 lines
lib/efi_loader/efi_capsule.c +1
-1@@ -441,7 +441,7 @@ efi_status_t EFIAPI efi_update_capsule(unsigned int i;efi_status_t ret; -EFI_ENTRY ("%p, %lu, %llu\n" , capsule_header_array, capsule_count, +EFI_ENTRY ("%p, %zu, %llu\n" , capsule_header_array, capsule_count, scatter_gather_list);
ok
lib/efi_loader/efi_capsule.c efi_status_t EFIAPI efi_query_capsule_caps( · line 504
Quoted 8 lines
lib/efi_loader/efi_capsule.c +1
-1if (!capsule_count) {@@ -501,7 +501,7 @@ efi_status_t EFIAPI efi_query_capsule_caps(unsigned int i;efi_status_t ret; - EFI_ENTRY("%p, %lu, %p, %p\n", capsule_header_array, capsule_count, + EFI_ENTRY("%p, %zu, %p, %p\n", capsule_header_array, capsule_count,
ok
Quoted 8 lines
lib/efi_loader/efi_capsule.c +0
-0maximum_capsule_size, reset_type);if (!maximum_capsule_size) {lib/efi_loader/efi_firmware.c +0
-0
lib/efi_loader/efi_firmware.c efi_status_t EFIAPI efi_firmware_fit_set_image( · line 303
Quoted 6 lines
lib/efi_loader/efi_firmware.c +1
-1@@ -299,7 +299,7 @@ efi_status_t EFIAPI efi_firmware_fit_set_image( efi_status_t (*progress)(efi_uintn_t completion), u16 **abort_reason) { - EFI_ENTRY("%p %d %p %ld %p %p %p\n", this, image_index, image, + EFI_ENTRY("%p %d %p %zd %p %p %p\n", this, image_index, image, image_size, vendor_code, progress, abort_reason);
ok
lib/efi_loader/efi_firmware.c efi_status_t EFIAPI efi_firmware_raw_set_image( · line 417
Quoted 8 lines
lib/efi_loader/efi_firmware.c +1
-1if (!image || image_index !=1 )@@ -414,7 +414,7 @@ efi_status_t EFIAPI efi_firmware_raw_set_image(efi_status_t status;efi_uintn_t capsule_payload_size; - EFI_ENTRY("%p %d %p %ld %p %p %p\n", this, image_index, image, + EFI_ENTRY("%p %d %p %zd %p %p %p\n", this, image_index, image,
ok
Otherwise
Quoted 4 lines
lib/efi_loader/efi_firmware.c +0
-0image_size, vendor_code, progress, abort_reason);if (!image)
PATCH 3/7 pci: swap_case: Allow compilation on 32-bit machines
In reply to Simon GlassAt present this driver assumes that ulong is 64-bits long. On 32-bit machines it is not. Use the 64-bit code only on 64-bit machines.
---
drivers/misc/swap_case.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/misc/swap_case.c +11 -2
@@ -302,7 +302,6 @@ static int sandbox_swap_case_write_io(struct udevice *dev, unsigned int addr, }static int pci_ea_bar2_magic =PCI_EA_BAR2_MAGIC ; -static int pci_ea_bar4_magic =PCI_EA_BAR4_MAGIC ;static int sandbox_swap_case_map_physmem (struct udevice *dev,phys_addr_t addr,unsigned long *lenp,void **ptrp)
@@ -332,12 +331,22 @@ static int sandbox_swap_case_map_physmem(struct udevice *dev, *ptrp = &pci_ea_bar2_magic; *lenp =PCI_CAP_EA_SIZE_LO ;break ; +#ifdef CONFIG_HOST_64BIT +/* +* This cannot be work on a 32-bit machine since *lenp is ulong +* which is 32-bits, but it needs to have a 64-bit value +* assigned +*/ case (phys_addr_t)((PCI_CAP_EA_BASE_HI4 <<32 ) | -PCI_CAP_EA_BASE_LO4 ): +PCI_CAP_EA_BASE_LO4 ): { +static int pci_ea_bar4_magic =PCI_EA_BAR4_MAGIC ; + *ptrp = &pci_ea_bar4_magic; *lenp = (PCI_CAP_EA_SIZE_HI <<32 ) |PCI_CAP_EA_SIZE_LO ;break ; + } +#endif default :return -ENOENT ; }
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
PATCH 3/7 pci: swap_case: Allow compilation on 32-bit machines
Quoted 2 lines · Simon Glass
At present this driver assumes that ulong is 64-bits long. On 32-bit machines it is not. Use the 64-bit code only on 64-bit machines.
The commit title and message leaves it open if this is only to make compilation work or if the code works correctly on 32-bit with this patch.
Best regards
Heinrich
Quoted 44 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/misc/swap_case.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)drivers/misc/swap_case.c +11
-2@@ -302,7 +302,6 @@ static int sandbox_swap_case_write_io(struct udevice *dev, unsigned int addr, }static int pci_ea_bar2_magic =PCI_EA_BAR2_MAGIC ; -static int pci_ea_bar4_magic =PCI_EA_BAR4_MAGIC ;static int sandbox_swap_case_map_physmem (struct udevice *dev,phys_addr_t addr,unsigned long *lenp,void **ptrp)@@ -332,12 +331,22 @@ static int sandbox_swap_case_map_physmem(struct udevice *dev, *ptrp = &pci_ea_bar2_magic; *lenp =PCI_CAP_EA_SIZE_LO ;break ; +#ifdef CONFIG_HOST_64BIT +/* +* This cannot be work on a 32-bit machine since *lenp is ulong +* which is 32-bits, but it needs to have a 64-bit value +* assigned +*/ case (phys_addr_t)((PCI_CAP_EA_BASE_HI4 <<32 ) | -PCI_CAP_EA_BASE_LO4 ): +PCI_CAP_EA_BASE_LO4 ): { +static int pci_ea_bar4_magic =PCI_EA_BAR4_MAGIC ; + *ptrp = &pci_ea_bar4_magic; *lenp = (PCI_CAP_EA_SIZE_HI <<32 ) |PCI_CAP_EA_SIZE_LO ;break ; + } +#endif default :return -ENOENT ; }
PATCH 4/7 tpm: Correct warning on 32-bit build
In reply to Simon GlassFix the warning:
drivers/tpm/tpm2_tis_sandbox.c: In function ?sandbox_tpm2_xfer?:drivers/tpm/tpm2_tis_sandbox.c:288:48: warning: format ?%ld? expects
argument of type ?long int?, but argument 2 has type ?size_t? {aka ?unsigned int?} [-Wformat=]
printf("TPM2: Unmatching length, received: %ld, expected: %d\n",
~~^
%d
send_size, length);
~~~~~~~~~---
drivers/tpm/tpm2_tis_sandbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tpm/tpm2_tis_sandbox.c +1 -1
@@ -285,7 +285,7 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const u8 *sendbuf, length =get_unaligned_be32 (sent); sent +=sizeof (length);if (length != send_size) { -printf ("TPM2: Unmatching length, received: %ld, expected: %d\n" , +printf ("TPM2: Unmatching length, received: %zd, expected: %d\n" , send_size, length); rc =TPM2_RC_SIZE ;sandbox_tpm2_fill_buf (recv, recv_len, tag, rc);
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
PATCH 4/7 tpm: Correct warning on 32-bit build
Quoted 23 lines · Simon Glass
Fix the warning:
drivers/tpm/tpm2_tis_sandbox.c: In function ?sandbox_tpm2_xfer?:drivers/tpm/tpm2_tis_sandbox.c:288:48: warning: format ?%ld? expectsargument of type ?long int?, but argument 2 has type ?size_t? {aka ?unsigned int?} [-Wformat=] printf("TPM2: Unmatching length, received: %ld, expected: %d\n", ~~^ %d send_size, length); ~~~~~~~~~Signed-off-by Simon Glass <[email protected]>---
drivers/tpm/tpm2_tis_sandbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/tpm/tpm2_tis_sandbox.c +0
-0
drivers/tpm/tpm2_tis_sandbox.c static int sandbox_tpm2_xfer(struct udevice *dev, const u8 *sendbuf, · line 288
Quoted 5 lines
drivers/tpm/tpm2_tis_sandbox.c +1
-1@@ -285,7 +285,7 @@ static int sandbox_tpm2_xfer(struct udevice *dev, const u8 *sendbuf, length =get_unaligned_be32 (sent); sent +=sizeof (length);if (length != send_size) { - printf("TPM2: Unmatching length, received: %ld, expected: %d\n", + printf("TPM2: Unmatching length, received: %zd, expected: %d\n",
Quoted 4 lines
drivers/tpm/tpm2_tis_sandbox.c +0
-0send_size, length); rc =TPM2_RC_SIZE ;sandbox_tpm2_fill_buf (recv, recv_len, tag, rc);
PATCH 4/7 tpm: Correct warning on 32-bit build
In reply to Simon GlassQuoted 7 lines · Simon Glass
Fix the warning:
drivers/tpm/tpm2_tis_sandbox.c: In function ?sandbox_tpm2_xfer?:drivers/tpm/tpm2_tis_sandbox.c:288:48: warning: format ?%ld? expects
argument of type ?long int?, but argument 2 has type ?size_t? {aka ?unsigned int?} [-Wformat=]
printf("TPM2: Unmatching length, received: %ld, expected: %d\n",
Quoted 7 lines
~~^ %d send_size, length); ~~~~~~~~~Signed-off-by Simon Glass <[email protected]>Reviewed-by Heinrich Schuchardt <[email protected]>
Applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210315/8ba1167b/attachment.sig>
PATCH 5/7 test: acpi: Fix warnings on 32-bit build
In reply to Simon GlassSome format strings use the wrong type. Fix them.
Example warnings:
In file included from test/dm/acpi.c:22:test/dm/acpi.c: In function ?dm_test_acpi_cmd_list?:test/dm/acpi.c:362:21: warning: format ?%lx? expects argument of type
?long unsigned int?, but argument 4 has type ?unsigned int? [-Wformat=] ut_assert_nextline("RSDP %08lx %06lx (v02 U-BOOT)", addr,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sizeof(struct acpi_rsdp));
~~~~~~~~~~~~~~~~~~~~~~~~
include/test/ut.h:282:33: note: in definition of macro ?ut_assert_nextline?
if (ut_check_console_line(uts, fmt, ##args)) { \
^~~---
test/dm/acpi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
test/dm/acpi.c +6 -6
@@ -359,24 +359,24 @@ static int dm_test_acpi_cmd_list(struct unit_test_state *uts)run_command ("acpi list" ,0 ); addr = (ulong )map_to_sysmem (buf);ut_assert_nextline ("ACPI tables start at %lx" , addr); -ut_assert_nextline ("RSDP %08lx %06lx (v02 U-BOOT)" , addr, +ut_assert_nextline ("RSDP %08lx %06zx (v02 U-BOOT)" , addr,sizeof (struct acpi_rsdp )); addr =ALIGN (addr +sizeof (struct acpi_rsdp ),16 ); -ut_assert_nextline ("RSDT %08lx %06lx (v01 U-BOOT U-BOOTBL %x INTL 0)" , +ut_assert_nextline ("RSDT %08lx %06zx (v01 U-BOOT U-BOOTBL %x INTL 0)" , addr,sizeof (struct acpi_table_header ) +3 *sizeof (u32),U_BOOT_BUILD_DATE ); addr =ALIGN (addr +sizeof (struct acpi_rsdt ),16 ); -ut_assert_nextline ("XSDT %08lx %06lx (v01 U-BOOT U-BOOTBL %x INTL 0)" , +ut_assert_nextline ("XSDT %08lx %06zx (v01 U-BOOT U-BOOTBL %x INTL 0)" , addr,sizeof (struct acpi_table_header ) +3 *sizeof (u64),U_BOOT_BUILD_DATE ); addr =ALIGN (addr +sizeof (struct acpi_xsdt ),64 ); -ut_assert_nextline ("DMAR %08lx %06lx (v01 U-BOOT U-BOOTBL %x INTL 0)" , +ut_assert_nextline ("DMAR %08lx %06zx (v01 U-BOOT U-BOOTBL %x INTL 0)" , addr,sizeof (struct acpi_dmar ),U_BOOT_BUILD_DATE ); addr =ALIGN (addr +sizeof (struct acpi_dmar ),16 ); -ut_assert_nextline ("DMAR %08lx %06lx (v01 U-BOOT U-BOOTBL %x INTL 0)" , +ut_assert_nextline ("DMAR %08lx %06zx (v01 U-BOOT U-BOOTBL %x INTL 0)" , addr,sizeof (struct acpi_dmar ),U_BOOT_BUILD_DATE ); addr =ALIGN (addr +sizeof (struct acpi_dmar ),16 ); -ut_assert_nextline ("DMAR %08lx %06lx (v01 U-BOOT U-BOOTBL %x INTL 0)" , +ut_assert_nextline ("DMAR %08lx %06zx (v01 U-BOOT U-BOOTBL %x INTL 0)" , addr,sizeof (struct acpi_dmar ),U_BOOT_BUILD_DATE );ut_assert_console_end ();
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
PATCH 5/7 test: acpi: Fix warnings on 32-bit build
Quoted 9 lines · Simon Glass
Some format strings use the wrong type. Fix them.
Example warnings:
In file included from
test/dm/acpi.c:22:test/dm/acpi.c: In function ?dm_test_acpi_cmd_list?:test/dm/acpi.c:362:21: warning: format ?%lx? expects argument of type
?long unsigned int?, but argument 4 has type ?unsigned int? [-Wformat=] ut_assert_nextline("RSDP %08lx %06lx (v02 U-BOOT)", addr,
Quoted 8 lines
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sizeof(struct acpi_rsdp)); ~~~~~~~~~~~~~~~~~~~~~~~~ include/test/ut.h:282:33: note: in definition of macro ?ut_assert_nextline? if (ut_check_console_line(uts, fmt, ##args)) { \ ^~~Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210315/db4d6397/attachment.sig>
PATCH 6/7 doc: sandbox: Fix up dependencies
In reply to Simon GlassThese are out of date. Update them and point to the existing build instructions to avoid duplication.
---
doc/arch/sandbox.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
doc/arch/sandbox.rst +5 -4
@@ -37,11 +37,12 @@ Note that standalone/API support is not available at present. Prerequisites ------------- -Here are some packages that are worth installing if you are doing sandbox or -tools development in U-Boot: +First install the dependencies noted in :doc:`../build/gcc`. - python3-pytest lzma lzma-alone lz4 python3 python3-virtualenv - libssl1.0-dev +Here are some extra packages that are worth installing if you are doing sandbox +or tools development in U-Boot: + + lzma lz4 python3-virtualenv Basic Operation
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
PATCH 6/7 doc: sandbox: Fix up dependencies
Quoted 17 lines · Simon Glass
These are out of date. Update them and point to the existing build instructions to avoid duplication.
Signed-off-by Simon Glass <[email protected]>---
doc/arch/sandbox.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)doc/arch/sandbox.rst +0
-0@@ -37,11 +37,12 @@ Note that standalone/API support is not available at present. Prerequisites -------------
doc/arch/sandbox.rst Note that standalone/API support is not available at present. · line 45
Quoted 10 lines
doc/arch/sandbox.rst +5
-4-Here are some packages that are worth installing if you are doing sandbox or -tools development in U-Boot: +First install the dependencies noted in :doc:`../build/gcc`. - python3-pytest lzma lzma-alone lz4 python3 python3-virtualenv - libssl1.0-dev +Here are some extra packages that are worth installing if you are doing sandbox +or tools development in U-Boot: + + lzma lz4 python3-virtualenv
I would prefer to add these to doc/build/gcc.rst
Best regards
Heinrich
Quoted 4 lines
doc/arch/sandbox.rst +0
-0Basic Operation
PATCH 7/7 doc: sandbox: Update instructions on quitting
In reply to Simon GlassThe 'reset' command now resets sandbox but does not quit it. Fix the instructions.
---
doc/arch/sandbox.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
doc/arch/sandbox.rst +1 -1
@@ -77,7 +77,7 @@ console:: You can issue commands as your would normally. If the command you want is not supported you can add it to include/configs/sandbox.h. -To exit, type 'reset' or press Ctrl-C. +To exit, type 'poweroff' or press Ctrl-C. Console / LCD support
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
PATCH 7/7 doc: sandbox: Update instructions on quitting
Quoted 5 lines · Simon Glass
The 'reset' command now resets sandbox but does not quit it. Fix the instructions.
Fixes 329dccc0675 ("sandbox: implement reset")Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210315/e1dce1dd/attachment.sig>
cover Fix compiler warnings for 32-bit ARM
In reply to Simon GlassQuoted 7 lines · Simon Glass
These were noticed when building sandbox on a Raspberry Pi 400, which uses 32-bit linux.
To make this work, I enabled
CONFIG_HOST_32BITin 'make menuconfig'. It would be nice if that were automatic, since we have the logic already inarch/sandbox/config.mk
Quoted 5 lines
There are still many errors of the form:
/usr/bin/ld: warning:arch/sandbox/cpu/start.ouses 2-bytewchar_tyet the
output is to use 4-bytewchar_t; use ofwchar_tvalues across objects may fail
For the compiler we use -fshort-wchar.
https://stackoverflow.com/questions/19489354/how-to-set-2-byte-wchar-t-output/23896853
discusses the warning. It can be suppressed with a linker flag.
The best thing to do would be to replace all L"" constants by u"" constants and eliminate -fshort-wchar from our compiler flags.
This requires C11 which we already use since 2018.
Best regards
Heinrich
Quoted 24 lines
I am not sure how to fix those, but they are not fatal (sandbox still runs).
Simon Glass (7):
mkeficapsule: Correctprintf()strings
efi: Fix compiler warnings
pci:swap_case: Allow compilation on 32-bit machines
tpm: Correct warning on 32-bit build
test: acpi: Fix warnings on 32-bit build
doc: sandbox: Fix up dependencies
doc: sandbox: Update instructions on quittingcmd/efidebug.c | 2 +- doc/arch/sandbox.rst | 11 ++++++----- drivers/misc/swap_case.c | 13 +++++++++++-- drivers/tpm/tpm2_tis_sandbox.c | 2 +- lib/efi_loader/efi_capsule.c | 4 ++-- lib/efi_loader/efi_firmware.c | 4 ++-- test/dm/acpi.c | 12 ++++++------ tools/mkeficapsule.c | 14 +++++++------- 8 files changed, 36 insertions(+), 26 deletions(-)