From 8c22bbbbc8f8e79e09b85b2f55d5b479d4402439 Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Tue, 3 Sep 2019 09:15:22 +0100 Subject: [PATCH] Use PRIu32 to print uint32_t variable As the variable underlying type size is different depending on the toolchain used --- features/cellular/framework/AT/ATHandler.cpp | 2 +- features/frameworks/TARGET_PSA/val_greentea.cpp | 2 +- platform/source/mbed_error.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/features/cellular/framework/AT/ATHandler.cpp b/features/cellular/framework/AT/ATHandler.cpp index cfc86ec54a..c9741fcc14 100644 --- a/features/cellular/framework/AT/ATHandler.cpp +++ b/features/cellular/framework/AT/ATHandler.cpp @@ -1365,7 +1365,7 @@ void ATHandler::write_int(int32_t param) // write the integer subparameter const int32_t str_len = 12; char number_string[str_len]; - int32_t result = sprintf(number_string, "%ld", param); + int32_t result = sprintf(number_string, "%" PRIi32, param); if (result > 0 && result < str_len) { (void)write(number_string, strlen(number_string)); } diff --git a/features/frameworks/TARGET_PSA/val_greentea.cpp b/features/frameworks/TARGET_PSA/val_greentea.cpp index 6498c9b6ee..6f71db388f 100644 --- a/features/frameworks/TARGET_PSA/val_greentea.cpp +++ b/features/frameworks/TARGET_PSA/val_greentea.cpp @@ -67,7 +67,7 @@ val_status_t mbed_val_execute_non_secure_tests(uint32_t test_num, client_test_t while (tests_list[i] != NULL) { memset(testcase_name, 0, 100); - sprintf(testcase_name, "Check%d", i); + sprintf(testcase_name, "Check%" PRIu32, i); GREENTEA_TESTCASE_START(testcase_name); if (server_hs == TRUE) { diff --git a/platform/source/mbed_error.c b/platform/source/mbed_error.c index 8e9b81c6de..c00c86a550 100644 --- a/platform/source/mbed_error.c +++ b/platform/source/mbed_error.c @@ -305,7 +305,7 @@ WEAK MBED_NORETURN mbed_error_status_t mbed_error(mbed_error_status_t error_stat mbed_error_printf("\n= System will be rebooted due to a fatal error =\n"); if (report_error_ctx->error_reboot_count >= MBED_CONF_PLATFORM_ERROR_REBOOT_MAX) { //We have rebooted more than enough, hold the system here. - mbed_error_printf("= Reboot count(=%ld) reached maximum, system will halt after rebooting =\n", report_error_ctx->error_reboot_count); + mbed_error_printf("= Reboot count(=%" PRIi32") reached maximum, system will halt after rebooting =\n", report_error_ctx->error_reboot_count); } #endif system_reset();//do a system reset to get the system rebooted