ec/google/wilco/mailbox: Fix format warning by using size_t length modifier

Building google/sarien with a 64-bit compiler (x86_64-linux-gnu) fails
with the error below.

    src/ec/google/wilco/mailbox.c: In function 'wilco_ec_transfer':
    src/ec/google/wilco/mailbox.c:184:43: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
      184 |   printk(BIOS_ERR, "%s: data too short (%lu bytes, expected %zu)",
          |                                         ~~^
          |                                           |
          |                                           long unsigned int
          |                                         %u
      185 |          __func__, rs.data_size - skip_size, msg->response_size);
          |                    ~~~~~~~~~~~~~~~~~~~~~~~~
          |                                 |
          |                                 size_t {aka unsigned int}

`data_size` has type `uint16_t`, and `skip_size` has type `size_t`,
whose size differs in 32-bit (unsigned int) and 64-bit (unsigned long).
So use the length modifier `z` for a `size_t` argument.

Found-by: x86_64-linux-gnu-gcc-10 (Debian 10.2.1-6) 10.2.1 20210110
Change-Id: Ida27323daeed9b8ff487302d0f3d6fcce0bbb705
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/54786
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Duncan Laurie
This commit is contained in:
Paul Menzel 2021-05-21 10:37:38 +02:00 committed by Tim Wawrzynczak
parent ef41e8a44c
commit e84a014ee6
1 changed files with 1 additions and 1 deletions

View File

@ -181,7 +181,7 @@ static int wilco_ec_transfer(struct wilco_ec_message *msg)
skip_size = (msg->type == WILCO_EC_MSG_DEFAULT) ? 1 : 0;
if (msg->response_size > rs.data_size - skip_size) {
printk(BIOS_ERR, "%s: data too short (%lu bytes, expected %zu)",
printk(BIOS_ERR, "%s: data too short (%zu bytes, expected %zu)",
__func__, rs.data_size - skip_size, msg->response_size);
return -1;
}