1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/dist/tools/cppcheck
Martine Lenders ca32d7704f
cppcheck: output all annotations as error on script error
`cppcheck` has a non-zero exit code even on warnings, so to not confuse
contributors, align the annotation output with that.
2021-11-04 15:43:02 +01:00
..
check.sh cppcheck: output all annotations as error on script error 2021-11-04 15:43:02 +01:00
README.md cppcheck: extend cppcheck README example 2018-09-25 12:03:58 +02:00

About

This is a cppcheck wrapper script with appropriate parameters for checking RIOT. It accepts a branch name as an argument which is used to limit the scope of the check. Other parameters will be passed to cppcheck, so you can further modify its behavior.

Example usage

Check all files changed in the current branch against the branch named 'master':

./dist/tools/cppcheck/check.sh master

Check all files but ignore warnings about unused struct members:

./dist/tools/cppcheck/check.sh --suppress=unassignedVariable

Check all files changed in the current branch against the branch named 'master', ignoring warnings about unassigned variables:

./dist/tools/cppcheck/check.sh master  --suppress=unassignedVariable

Default options

This script suppresses warnings of the type "unusedStructMember" by default. If you want to get warnings about "unusedStructMembers" run the script with the --show-unused-struct option: ./dist/tools/cppcheck/check.sh --show-unused-struct [BRANCH] [options to be passed]

What to do about the findings

You should read the code carefully. While cppcheck certainly produces valuable information, it can also warn about code that is actually OK. If this happens, you can add an "inline suppression" and briefly state why this is required like this:

/* cppcheck-suppress passedByValue
 * (reason: <add rationale on why it is necessary to suppress this here>) */
timex_t timex_add(const timex_t a, const timex_t b);