1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#!/bin/sh
#
# Usage: cppcheck-wrapper.sh <file>
# Notes on suppressions
# - readdir_r is deprecated. See readdir_r(3)
# - We allow strtok if threadsafety is not a consideration
# - With the C89 kernel style, variableScope throws warnings, but not a problem
# - vsnprintf() is used in accordance with the man page, so not sure what the
# issue is
# - list.h and hashmap.{c,h} are copied from git/linux, so it's easier to keep
# them complete. It also makes the unit test work properly
suppressions="\
--suppress=readdirCalled:src/desktop.c \
--suppress=readdirCalled:src/icon-find.c \
--suppress=missingIncludeSystem \
--suppress=variableScope \
--suppress=nullPointer:src/jgmenu-obtheme.c \
--suppress=unusedFunction:src/hashmap.c \
--suppress=unusedFunction:src/hashmap.h \
--suppress=unusedFunction:src/list.h"
enable="\
--enable=warning \
--enable=style \
--enable=performance \
--enable=portability \
--enable=information \
--enable=missingInclude"
# When the whole program is scanned, we can also check for unused functions
test $# -eq 0 && enable="${enable} --enable=unusedFunction"
if test $# -eq 0; then
c=src/*.c
h=src/*.h
files="$c $h"
else
files="$@"
fi
cppcheck \
--inconclusive \
-DVERSION=3.4 \
-I src/ \
--std=c99 \
--library=/usr/share/cppcheck/cfg/gnu.cfg \
--quiet \
${enable} \
${suppressions} \
${files} \
2>&1 \
| grep -v 'Unmatched suppression'
|