mcuboot icon indicating copy to clipboard operation
mcuboot copied to clipboard

Many string formats are incorrect.

Open mastupristi opened this issue 2 months ago • 1 comments

in version 2.2.0 (2d61c318933819a0f4954fb2a5a957a62c6128ce). 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.

mastupristi avatar Sep 16 '25 11:09 mastupristi