Skip to content

Many string formats are incorrect. #2456

@mastupristi

Description

@mastupristi

in version 2.2.0 (2d61c31).
There are many strings with incorrect formats, and this causes a lot of warnings (or errors if you use -Werror like I do).

middleware/mcuboot/boot/nxp_mcux_sdk/boot.c:190:18: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
  190 |     BOOT_LOG_INF("Bootloader chainload address offset: 0x%x", rsp.br_image_off);
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~
      |                                                                  |
      |                                                                  uint32_t {aka long unsigned int}
middleware/mcuboot/boot/nxp_mcux_sdk/boot.c:190:59: note: format string is defined here
  190 |     BOOT_LOG_INF("Bootloader chainload address offset: 0x%x", rsp.br_image_off);
      |                                                          ~^
      |                                                           |
      |                                                           unsigned int
      |                                                          %lx
middleware/mcuboot/boot/nxp_mcux_sdk/boot.c:191:18: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'long unsigned int' [-Werror=format=]
  191 |     BOOT_LOG_INF("Reset_Handler address offset: 0x%x", rsp.br_image_off + rsp.br_hdr->ih_hdr_size);
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                         |
      |                                                                         long unsigned int
middleware/mcuboot/boot/nxp_mcux_sdk/boot.c:191:52: note: format string is defined here
  191 |     BOOT_LOG_INF("Reset_Handler address offset: 0x%x", rsp.br_image_off + rsp.br_hdr->ih_hdr_size);
      |                                                   ~^
      |                                                    |
      |                                                    unsigned int
      |                                                   %lx
ThirdParties/mcuboot/boot/bootutil/src/ed25519_psa.c:35:22: error: format '%d' expects argument of type 'int', but argument 2 has type 'psa_status_t' {aka 'long int'} [-Werror=format=]
   35 |         BOOT_LOG_ERR("PSA crypto init failed %d\n", status);
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~
      |                                                     |
      |                                                     psa_status_t {aka long int}
ThirdParties/mcuboot/boot/bootutil/src/ed25519_psa.c:35:47: note: format string is defined here
   35 |         BOOT_LOG_ERR("PSA crypto init failed %d\n", status);
      |                                              ~^
      |                                               |
      |                                               int
      |                                              %ld
ThirdParties/mcuboot/boot/bootutil/src/ed25519_psa.c:48:22: error: format '%d' expects argument of type 'int', but argument 2 has type 'psa_status_t' {aka 'long int'} [-Werror=format=]
   48 |         BOOT_LOG_ERR("ED25519 key import failed %d", status);
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~
      |                                                      |
      |                                                      psa_status_t {aka long int}
ThirdParties/mcuboot/boot/bootutil/src/ed25519_psa.c:48:50: note: format string is defined here
   48 |         BOOT_LOG_ERR("ED25519 key import failed %d", status);
      |                                                 ~^
      |                                                  |
      |                                                  int
      |                                                 %ld
ThirdParties/mcuboot/boot/bootutil/src/ed25519_psa.c:55:22: error: format '%d' expects argument of type 'int', but argument 2 has type 'psa_status_t' {aka 'long int'} [-Werror=format=]
   55 |         BOOT_LOG_ERR("ED25519 signature verification failed %d", status);
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~
      |                                                                  |
      |                                                                  psa_status_t {aka long int}
ThirdParties/mcuboot/boot/bootutil/src/ed25519_psa.c:55:62: note: format string is defined here
   55 |         BOOT_LOG_ERR("ED25519 signature verification failed %d", status);
      |                                                             ~^
      |                                                              |
      |                                                              int
      |                                                             %ld
ThirdParties/mcuboot/boot/bootutil/src/ed25519_psa.c:67:22: error: format '%d' expects argument of type 'int', but argument 2 has type 'psa_status_t' {aka 'long int'} [-Werror=format=]
   67 |         BOOT_LOG_WRN("Failed to destroy key %d", status);
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~
      |                                                  |
      |                                                  psa_status_t {aka long int}
ThirdParties/mcuboot/boot/bootutil/src/ed25519_psa.c:67:46: note: format string is defined here
   67 |         BOOT_LOG_WRN("Failed to destroy key %d", status);
      |                                             ~^
      |                                              |
      |                                              int
      |                                             %ld

The PRIxxx macros from <inttypes.h> should be used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions