Cleanup output format warnings (#904)

Use `PRIxxx` related macros to format the output strings so as to clear
compile warnings, e.g. PRIu32, PRId32, PRIX32, PRIX64 and so on.
And add the related macro definitions in platform_common.h if they
are not defined, as some compilers might not support them.
This commit is contained in:
Huang Qi
2021-12-20 15:51:36 +08:00
committed by GitHub
parent a41c1ad85c
commit 4cc4625a2b
9 changed files with 74 additions and 26 deletions

View File

@ -39,9 +39,11 @@ bh_log(LogLevel log_level, const char *file, int line, const char *fmt, ...)
s = t % 60;
mills = (uint32)(usec % 1000);
snprintf(buf, sizeof(buf), "%02u:%02u:%02u:%03u", h, m, s, mills);
snprintf(buf, sizeof(buf),
"%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ":%03" PRIu32, h, m, s,
mills);
os_printf("[%s - %X]: ", buf, (uint32)(uintptr_t)self);
os_printf("[%s - %" PRIXPTR "]: ", buf, (uintptr_t)self);
if (file)
os_printf("%s, line %d, ", file, line);
@ -71,8 +73,9 @@ bh_print_time(const char *prompt)
total_time_ms += curr_time_ms - last_time_ms;
os_printf("%-48s time of last stage: %u ms, total time: %u ms\n", prompt,
curr_time_ms - last_time_ms, total_time_ms);
os_printf("%-48s time of last stage: %" PRIu32 " ms, total time: %" PRIu32
" ms\n",
prompt, curr_time_ms - last_time_ms, total_time_ms);
last_time_ms = curr_time_ms;
}