From 7be44d2ad6a52c59147e804ffc13a86e0fd937cb Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Tue, 9 Nov 2021 08:36:52 +0100 Subject: 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/59055 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons Reviewed-by: Felix Held --- src/drivers/ipmi/ipmi_fru.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/drivers/ipmi') diff --git a/src/drivers/ipmi/ipmi_fru.c b/src/drivers/ipmi/ipmi_fru.c index 31ac6c0d9c..d26a9b752b 100644 --- a/src/drivers/ipmi/ipmi_fru.c +++ b/src/drivers/ipmi/ipmi_fru.c @@ -189,7 +189,7 @@ static enum cb_err read_fru_chassis_info_area(const int port, const uint8_t id, 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 @@ static enum cb_err read_fru_board_info_area(const int port, const uint8_t id, 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 @@ static enum cb_err read_fru_product_info_area(const int port, const uint8_t id, 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; -- cgit v1.2.3