In my embedded application I an EEPROM which starts at address 0. To make access easier I create a mapping structure and then map this to address zero. Unsurprisingly cppcheck flags all accesses as nullPointer, which is expected. #define EEprom (*((EEprom_t *) 0))
Version = eeprom_read_byte(&EEprom.EE_Version);
I tried to suppress these errors in the GUI client by adding a suppression which specifies error Id nullPointer and variable EEprom. Unfortunately it doesn't suppress anything.
If I remove the variable name from the suppression definition then the supress works, but of course it's dangerous to suppress all nullPointer errors.
In my embedded application I an EEPROM which starts at address 0. To make access easier I create a mapping structure and then map this to address zero. Unsurprisingly cppcheck flags all accesses as nullPointer, which is expected.
#define EEprom (*((EEprom_t *) 0)) Version = eeprom_read_byte(&EEprom.EE_Version);
I tried to suppress these errors in the GUI client by adding a suppression which specifies error Id nullPointer and variable EEprom. Unfortunately it doesn't suppress anything.
If I remove the variable name from the suppression definition then the supress works, but of course it's dangerous to suppress all nullPointer errors.
Is this a bug or am I doing something wrong?
Thanks!
hmm.. there is no variable here. It warns about the expression:
(EEprom_t*)0
. Not sure .. maybe it's ok to set that as variable name.A workaround could be:
And define
__cppcheck__
in the Cppcheck analysis.Thanks! Yes, agreed, it's an edge case so I'm happy to use the workaround.
Or:
Anyway.. I think it would be good to have the option to write a suppression comment for a macro:
I have created this ticket for that: https://trac.cppcheck.net/ticket/9800