Description
Many modules and the Font conversion tool have code that assign signed values to unsigned variables. This results is thousands of warnings for: “integer conversion resulted in a change of sign”
What MCU/Processor/Board and compiler are you using?
Processor is STM32F4
IDE is KEIL uVision MDK 5.27.1 with ARM V5.06 Update 6 toolchain.
What do you experience?
By default the ARM toolchain presents a warning if a signed value is assigned to an unsigned variable. When compiling code I recieve multiple warnings.
For example, compiling lv_draw_img.c
compiling lv_draw_img.c...
..\..\lvgl\src\lv_draw\lv_draw_img.c(53): warning: #68-D: integer conversion resulted in a change of sign
lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL, -1, -1, NULL);
..\..\lvgl\src\lv_draw\lv_draw_img.c(53): warning: #68-D: integer conversion resulted in a change of sign
lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL, -1, -1, NULL);
..\..\lvgl\src\lv_draw\lv_draw_img.c(63): warning: #68-D: integer conversion resulted in a change of sign
lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL, -1, -1, NULL);
..\..\lvgl\src\lv_draw\lv_draw_img.c(63): warning: #68-D: integer conversion resulted in a change of sign
lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL, -1, -1, NULL);
..\..\lvgl\src\lv_draw\lv_draw_img.c(496): warning: #68-D: integer conversion resulted in a change of sign
lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, cdsc->dec_dsc.error_msg, LV_TXT_FLAG_NONE, NULL, -1, -1, NULL);
..\..\lvgl\src\lv_draw\lv_draw_img.c(497): warning: #68-D: integer conversion resulted in a change of sign
What do you expect?
Assigning variables and parameters should either, use appropriate sign, or the value should be cast, or use a pre-compile define to prevent warnings.
Code to reproduce
Example code that produces the warning from lv_draw_img.c line 53. The -1 in the parameter generates the warning.
lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL, -1, -1, NULL);
Example code that produces the warning from lv_font_roboto_12.c line 1032. The -2 assignment to .ofs_y generates a warning.
{.bitmap_index = 49, .adv_w = 112, .box_h = 12, .box_w = 7, .ofs_x = 0, .ofs_y = -2},
CORRECTION:
The kern_class_values are what are generating warnings.
static const uint8_t kern_class_values[] =
{
0, -16, 22, 0, 0, -59, -16, -45,
...