fix(refresh) switch to portable format specifiers (#2781)

Some platforms define uint32_t as "unsigned long" rather than "unsigned int".
The %d format specifier is mismatched and the C99 format macros are the only
portable way to handle these types.

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
Kevin Thibedeau
2021-11-09 10:03:06 -05:00
committed by GitHub
parent 462fbcbf49
commit 09e19bb687
3 changed files with 6 additions and 1 deletions

View File

@@ -307,7 +307,8 @@ void _lv_disp_refr_timer(lv_timer_t * tmr)
uint32_t used_size = mon.total_size - mon.free_size;;
uint32_t used_kb = used_size / 1024;
uint32_t used_kb_tenth = (used_size - (used_kb * 1024)) / 102;
lv_label_set_text_fmt(mem_label, "%d.%d kB used (%d %%)\n%d%% frag.", used_kb, used_kb_tenth, mon.used_pct,
lv_label_set_text_fmt(mem_label, "%" LV_PRIu32 ".%" LV_PRIu32 " kB used (%d %%)\n" \
"%d%% frag.", used_kb, used_kb_tenth, mon.used_pct,
mon.frag_pct);
}
#endif

View File

@@ -39,12 +39,15 @@
# include <inttypes.h>
/* platform-specific printf format for int32_t, usually "d" or "ld" */
# define LV_PRId32 PRId32
# define LV_PRIu32 PRIu32
# else
# define LV_PRId32 "d"
# define LV_PRIu32 "u"
# endif
#else
/* hope this is correct for ports without __has_include or without inttypes.h */
# define LV_PRId32 "d"
# define LV_PRIu32 "u"
#endif
#ifdef __cplusplus