Menu

MISRA C incomplete boolean type check

Rob Gordon
2018-09-28
2018-09-29
  • Rob Gordon

    Rob Gordon - 2018-09-28

    In the cppcheck source, checkbool.cpp::isBool(), the values of "bool" and "_Bool" (from C99) are evaluated.
    In misra.py, isBoolExpression() only checks for "bool". It should also check for "_Bool" for consistency.
    Both places check for "true" and "false" so that is consistent with stdbool.h usage added for C99.

    Since MISRA is heavily used by the AUTOSAR standard, they are some additional extended definitions that would be useful to add in the .cpp and .py checks. AUTOSAR adds Platform_Types.h which defines: "boolean", "TRUE", and "FALSE". Could these be added for the next release?

    Cheers.

     
  • Daniel Marjamäki

    In misra.py, isBoolExpression() only checks for "bool". It should also check for "_Bool" for consistency.

    yes. well to be accurate the misra addon could check if c99 is enabled. (it should be enabled by default I think).

    do you think you could create a pull request on github? please add some test cases in cppcheck/addons/test/misra-test.c and update the cppcheck/addons/misra.py file?

    Could these be added for the next release?

    I am not accepting further improvements now for 1.85. We are trying to improve the robustness right now. But for 1.86 it's possible.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.