tools: add style checking scripts

Add shell script and modified checkpatch.pl for use with patch files
targeting FRR.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2017-12-12 15:21:20 -05:00
parent 97c772b30b
commit 3e4ae70277
No known key found for this signature in database
GPG Key ID: DAF48E0F57E0834F
2 changed files with 6515 additions and 0 deletions

6487
tools/checkpatch.pl Executable file

File diff suppressed because it is too large Load Diff

28
tools/checkpatch.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
# Check a patch for style errors.
# Usage:
# ./checkpatch.sh <patch>
checkpatch="./checkpatch.pl --no-tree -f"
git status | grep "working directory clean"
if [ $? -ne 0 ]; then
echo "[!] git working directory must be clean."
exit 1
fi
mkdir -p f1 f2
bash -c "cd .. && git apply $1 2> /dev/null"
mod=$(git ls-files -m .. | grep ".*\.[ch]")
cp $mod f1/
git reset --hard
cp $mod f2/
for file in f1/*; do
$checkpatch $file > "$file"_cp 2> /dev/null
done
for file in f2/*; do
$checkpatch $file > "$file"_cp 2> /dev/null
done
for file in f1/*_cp; do
diff $file f2/$(basename $file) | grep -A3 "ERROR\|WARNING"
done
rm -rf f1 f2