checkpatch.sh: Simplify the code logic, no functional change
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
d53566118e
commit
cf674ed51c
@ -18,6 +18,7 @@
|
||||
|
||||
TOOLDIR=$(dirname $0)
|
||||
|
||||
check=check_patch
|
||||
fail=0
|
||||
range=0
|
||||
spell=0
|
||||
@ -36,10 +37,12 @@ usage() {
|
||||
echo " git diff --cached | ./tools/checkpatch.sh -"
|
||||
echo "Where a <commit list> is any syntax supported by git for specifying git revision, see GITREVISIONS(7)"
|
||||
echo "Where a <patch file names> is a space separated list of patch file names or wildcard. or *.patch"
|
||||
|
||||
exit $@
|
||||
}
|
||||
|
||||
check_file() {
|
||||
$TOOLDIR/nxstyle $@
|
||||
$TOOLDIR/nxstyle $@ 2>&1
|
||||
ret=$?
|
||||
if [ $ret != 0 ]; then
|
||||
fail=$ret
|
||||
@ -59,9 +62,9 @@ check_ranges() {
|
||||
if [[ $REPLY =~ ^(\+\+\+\ (b/)?([^[:blank:]]+).*)$ ]]; then
|
||||
if [ "$ranges" != "" ]; then
|
||||
if [ $range != 0 ]; then
|
||||
check_file $ranges $path 2>&1
|
||||
check_file $ranges $path
|
||||
else
|
||||
check_file $path 2>&1
|
||||
check_file $path
|
||||
fi
|
||||
fi
|
||||
path=${BASH_REMATCH[3]}
|
||||
@ -72,9 +75,9 @@ check_ranges() {
|
||||
done
|
||||
if [ "$ranges" != "" ]; then
|
||||
if [ $range != 0 ]; then
|
||||
check_file $ranges $path 2>&1
|
||||
check_file $ranges $path
|
||||
else
|
||||
check_file $path 2>&1
|
||||
check_file $path
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -106,53 +109,39 @@ fi
|
||||
|
||||
while [ ! -z "$1" ]; do
|
||||
case "$1" in
|
||||
-h )
|
||||
usage
|
||||
exit 0
|
||||
- )
|
||||
check_ranges
|
||||
;;
|
||||
-c )
|
||||
spell=1
|
||||
;;
|
||||
-f )
|
||||
check=check_file
|
||||
;;
|
||||
-g )
|
||||
check=check_commit
|
||||
;;
|
||||
-h )
|
||||
usage 0
|
||||
;;
|
||||
-p )
|
||||
check=check_patch
|
||||
;;
|
||||
-r )
|
||||
range=1
|
||||
;;
|
||||
-p )
|
||||
shift
|
||||
patches=$@
|
||||
break
|
||||
;;
|
||||
-g )
|
||||
shift
|
||||
commits=$@
|
||||
break
|
||||
;;
|
||||
-f )
|
||||
shift
|
||||
files=$@
|
||||
break
|
||||
;;
|
||||
- )
|
||||
check_ranges
|
||||
break
|
||||
-* )
|
||||
usage 1
|
||||
;;
|
||||
* )
|
||||
patches=$@
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
for patch in $patches; do
|
||||
check_patch $patch
|
||||
done
|
||||
|
||||
for commit in $commits; do
|
||||
check_commit $commit
|
||||
done
|
||||
|
||||
for file in $files; do
|
||||
check_file $file 2>&1
|
||||
for arg in $@; do
|
||||
$check $arg
|
||||
done
|
||||
|
||||
exit $fail
|
||||
|
Loading…
Reference in New Issue
Block a user