I have configured cppcheck2.16.0 in order to parse misra informations.
It seems to me that everything is working correctly but I have a strange behavior related to the rule in object.
I am working with arm-none-eabi-gcc, and I am using stdint.h as a source for the types defined as integers in order to guarantee the correct int.
What I am noticing is the following:
I have this line of code that triggers the warning:
The two lines of code are in the same source file, therefore I can exclude that they are treated in a different way.
I have different warnings and different "not warning in the same file". What I can think about is that in the first case, the one with the warning, the UINT8_C is inside an if condition, while in the second case, UINT8_C is used in an assignment to a variable.
This seems always the case except in a couple of occasions like
switch ((data[0] & UINT8_C(0xF0)) >> UINT8_C(4))
if (minDelayMs >= UINT8_C(0xF1)) {
It seems to me a false positive. C compiler does not issue any warning for the file. Just the misra parser.
Do you see anything wrong with the use of UINT8_C in those situations?
Thank you in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have configured cppcheck2.16.0 in order to parse misra informations.
It seems to me that everything is working correctly but I have a strange behavior related to the rule in object.
I am working with arm-none-eabi-gcc, and I am using stdint.h as a source for the types defined as integers in order to guarantee the correct int.
What I am noticing is the following:
I have this line of code that triggers the warning:
while the following is accepted:
The two lines of code are in the same source file, therefore I can exclude that they are treated in a different way.
I have different warnings and different "not warning in the same file". What I can think about is that in the first case, the one with the warning, the UINT8_C is inside an if condition, while in the second case, UINT8_C is used in an assignment to a variable.
This seems always the case except in a couple of occasions like
It seems to me a false positive. C compiler does not issue any warning for the file. Just the misra parser.
Do you see anything wrong with the use of UINT8_C in those situations?
Thank you in advance
I would like to add that refactoring the code in this way
the warning disappears.
It seems a false positive to me.
What do you think?
Thanks for the bug report. I can reproduce and I agree it's a FP. I have created this ticket:
https://trac.cppcheck.net/ticket/13370