From 86d488ce66e0b3affb4aec48f10ad5152a861f49 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 15 Feb 2018 13:37:03 -0500 Subject: [PATCH] tools: improve checkpatch.sh * Send reports to stderr; this allows you to get just the end result by redirecting stderr * Don't attempt to copy nonexistent files Signed-off-by: Quentin Young --- tools/checkpatch.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/checkpatch.sh b/tools/checkpatch.sh index 3536df79a9..f55692096f 100755 --- a/tools/checkpatch.sh +++ b/tools/checkpatch.sh @@ -45,10 +45,19 @@ echo $mod if [ -z "$mod" ]; then echo "There doesn't seem to be any changes." else - cp $tree/$mod /tmp/f1/ + echo "Copying source to temp directory..." + for file in $mod; do + echo "$tree/$file --> /tmp/f1/$file" + cp $tree/$file /tmp/f1/ + done git -C $tree reset --hard git -C $tree clean -fd - cp $tree/$mod /tmp/f2/ + for file in $mod; do + if [ -f $tree/$file ]; then + echo "$tree/$file --> /tmp/f2/$file" + cp $tree/$file /tmp/f2/ + fi + done echo "Running style checks..." for file in /tmp/f1/*; do echo "$checkpatch $file > $file _cp" @@ -60,12 +69,12 @@ else done echo "Done." for file in /tmp/f1/*_cp; do - echo "Report for $(basename $file _cp)" - echo "===============================================" + echo "Report for $(basename $file _cp)" 1>&2 + echo "===============================================" 1>&2 if [ -a /tmp/f2/$(basename $file) ]; then - diff $file /tmp/f2/$(basename $file) | grep -v "normally be const" | grep -A3 "ERROR\|WARNING" + diff $file /tmp/f2/$(basename $file) | grep -v "normally be const" | grep -A3 "ERROR\|WARNING" 1>&2 else - cat $file | grep -v "normally be const" | grep -A3 "ERROR\|WARNING" + cat $file | grep -v "normally be const" | grep -A3 "ERROR\|WARNING" 1>&2 fi if [ "$?" -eq "0" ]; then stat=1 -- 2.39.5