drivers/ipmi: Use correct unsigned int length modifier
Building an image for OCP DeltaLake with `x86_64-linux-gnu-gcc-11` fails
with the format warning below as the size of char * differs between
32-bit and 64-bit.
CC ramstage/drivers/ipmi/ipmi_fru.o
src/drivers/ipmi/ipmi_fru.c: In function 'read_fru_chassis_info_area':
src/drivers/ipmi/ipmi_fru.c:192:57: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'unsigned int' [-Werror=format=]
192 | printk(BIOS_ERR, "%s failed to malloc %ld bytes for "
| ~~^
| |
| long int
| %d
193 | "chassis custom data array.\n", __func__,
194 | info->custom_count * sizeof(char *));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| unsigned int
src/drivers/ipmi/ipmi_fru.c: In function 'read_fru_board_info_area':
src/drivers/ipmi/ipmi_fru.c:291:57: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'unsigned int' [-Werror=format=]
291 | printk(BIOS_ERR, "%s failed to malloc %ld bytes for "
| ~~^
| |
| long int
| %d
292 | "board custom data array.\n", __func__,
293 | info->custom_count * sizeof(char *));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| unsigned int
src/drivers/ipmi/ipmi_fru.c: In function 'read_fru_product_info_area':
src/drivers/ipmi/ipmi_fru.c:398:57: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'unsigned int' [-Werror=format=]
398 | printk(BIOS_ERR, "%s failed to malloc %ld bytes for "
| ~~^
| |
| long int
| %d
399 | "product custom data array.\n", __func__,
400 | info->custom_count * sizeof(char *));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| unsigned int
Fix the mismatches in `read_fru_chassis_info_area()` by using the length
modifier `z` for size_t as that is what `size_of` yields to.
Change-Id: If0c4266b19d56fa88abc397f305154d473ae1a93
Found-by: gcc (Debian 11.2.0-10) 11.2.0
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/59055
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
diff --git a/src/drivers/ipmi/ipmi_fru.c b/src/drivers/ipmi/ipmi_fru.c
index 31ac6c0..d26a9b7 100644
--- a/src/drivers/ipmi/ipmi_fru.c
+++ b/src/drivers/ipmi/ipmi_fru.c
@@ -189,7 +189,7 @@
info->chassis_custom = malloc(info->custom_count * sizeof(char *));
if (!info->chassis_custom) {
- printk(BIOS_ERR, "%s failed to malloc %ld bytes for "
+ printk(BIOS_ERR, "%s failed to malloc %zu bytes for "
"chassis custom data array.\n", __func__,
info->custom_count * sizeof(char *));
ret = CB_ERR;
@@ -288,7 +288,7 @@
info->board_custom = malloc(info->custom_count * sizeof(char *));
if (!info->board_custom) {
- printk(BIOS_ERR, "%s failed to malloc %ld bytes for "
+ printk(BIOS_ERR, "%s failed to malloc %zu bytes for "
"board custom data array.\n", __func__,
info->custom_count * sizeof(char *));
ret = CB_ERR;
@@ -395,7 +395,7 @@
info->product_custom = malloc(info->custom_count * sizeof(char *));
if (!info->product_custom) {
- printk(BIOS_ERR, "%s failed to malloc %ld bytes for "
+ printk(BIOS_ERR, "%s failed to malloc %zu bytes for "
"product custom data array.\n", __func__,
info->custom_count * sizeof(char *));
ret = CB_ERR;