Hello,
I have one application, where I store several copies of settings into internal flash. I made command "CAT" for list of all stored settings. To identify single store location as "empty" I simply check one byte if it has value 0xff (when flash location is erased). Microcontroller is STM32F0. Here is part of my code:
#define FLASH_STORE_ADR 0x8007c00 const settings_t settings_Store[SETTINGS_CATLEN] __attribute__((at(FLASH_STORE_ADR))); .... check = settings_Store[i].Ident[0]; if ((strlen(settings_Store[i].Ident) > 0) & (check!=0xff)) { DisplaySettings((settings_t *)&settings_Store[i]); } else { snprintf(izp, 32, " <Empty> "); USB_write((uint8_t *)izp, strlen(izp)); } ....
The IDE shows "warning: comparison of constant 255 with expression of type 'char' is always true". The code works as it should, but the warning is annoying. The warning is displayed only in IDE as exclamation mark. Build does not report any warnings.
Is there any option to avoid this warning?
complete project is here: e.pavlin.si/.../
Use && not &
Check that it is not 0xFF first in the comparison list, so if doesn't perform the string operation if it contains erased junk.
Thank you. It was my mistake. I used signed char instead of unsigned.
Marko