diff options
author | Wolfram Sang <wsa@the-dreams.de> | 2017-04-27 17:48:48 +0200 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2017-04-27 17:48:48 +0200 |
commit | f7849ada9866835e6ca819e68ebe54fc56e56537 (patch) | |
tree | 978bc5080ed680bd5984eadb1814bf61dcd39464 | |
parent | 702be62bed5c1601cddb2fb2c60afe72b29f14f6 (diff) | |
download | snippets-f7849ada9866835e6ca819e68ebe54fc56e56537.tar.gz |
scripts: add ninja-check
My most requested snippet so far.
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rwxr-xr-x | scripts/ninja-check | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/ninja-check b/scripts/ninja-check new file mode 100755 index 0000000..04c5d52 --- /dev/null +++ b/scripts/ninja-check @@ -0,0 +1,29 @@ +#!/bin/sh -u +# wrapper to call various static checkers for kernel builds. +# Use: make C=1 CHECK='ninja-check' ... +# done by Wolfram Sang in 2012-14, version 20140514 - WTFPLv2 + +check_for() +{ + command -v $1 > /dev/null + ret=$? + [ $ret -eq 0 ] && echo " $1" | tr a-z A-Z + return $ret +} + +# Get filename (last argument) +eval file_to_check=\${$#} + +check_for sparse && sparse -Wsparse-all "$@" + +check_for smatch && smatch --two-passes --project=kernel "$@" 1>&2 + +# Don't provide include-dirs since number of code paths increases drastically (#defines!) and '-f' checks all of them. Just suppress the warning. +check_for cppcheck && cppcheck -f -q --platform=unix64 --template=gcc --enable=all --language=c --suppress=missingInclude --suppress=clarifyCalculation --suppress=unmatchedSuppression --suppress=variableScope "$file_to_check" + +check_for spatch && MODE=report scripts/coccicheck "$file_to_check" 1>&2 + +check_for flawfinder && flawfinder --minlevel=0 --quiet --dataonly --singleline "$file_to_check" 1>&2 + +# RATS mainly checks for dangerous functions. Not so useful for kernel analysis. flawfinder does string checking, too. +#check_for rats && rats --resultsonly -w 3 "$file_to_check" 1>&2 |