This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Comparison of constant (checking if flash location is not 0xff)

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/.../