Is there a method or hint to indicate that "volatile uint32_t pointer" variables correspond to MMIO hardware registers so that certain checks can be skipped?
This causes a knownConditionTrueFalse error in the if statement after the loop
Also, if when there are multiple writes to the same hardware register in sequence cause redundantAssignment errors but it's quite common to require separate writes for an 'enable bit' and the 'config bits'
I'm using cppcheck v2.1 with "--enable=all --inconclusive" .
I'm be happy to wrap bits of the code above in a macro as a HINT because cppcheck is generally very useful with a great signal to noise ratio!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here's a simplified example of the issue. Whist creating this I noticed that using read-modify-write (&= |=) avoids the error or inserting a nop between the assignments also avoids the error.
That's probably a hint that I should tidy up the old code although skipping a read where it's unecessary for a hardware register is fairly common
Is there a method or hint to indicate that "volatile uint32_t pointer" variables correspond to MMIO hardware registers so that certain checks can be skipped?
This causes a knownConditionTrueFalse error in the if statement after the loop
Also, if when there are multiple writes to the same hardware register in sequence cause redundantAssignment errors but it's quite common to require separate writes for an 'enable bit' and the 'config bits'
I'm using cppcheck v2.1 with "--enable=all --inconclusive" .
I'm be happy to wrap bits of the code above in a macro as a HINT because cppcheck is generally very useful with a great signal to noise ratio!
The part with knownConditionTrueFalse could be related to or identical to https://trac.cppcheck.net/ticket/9808 .
Last edit: Andreas Grob 2020-07-30
Thanks, moving the decrement outside of the loop condition resolved the knownConditionTrueFalse warnings
hmm.. I guess
redundantAssignment
should not warn about volatile variables.Also cppcheck could assume that pointers with a fixed address are hardware related.
Which checks do you have problems with?
I created ticket https://trac.cppcheck.net/ticket/9825
which checks do you see problems with for volatile variables?
Here's a simplified example of the issue. Whist creating this I noticed that using read-modify-write (&= |=) avoids the error or inserting a nop between the assignments also avoids the error.
That's probably a hint that I should tidy up the old code although skipping a read where it's unecessary for a hardware register is fairly common