Debian Codegraph @

scripts/travis-checkpatch

raw
1 #!/bin/bash
2 # Copyright 2017 Mellanox Technologies Ltd.
3 # Licensed under BSD (MIT variant) or GPLv2. See COPYING.
4
5
6 if [ "x$TRAVIS_EVENT_TYPE" != "xpull_request" ]; then
7 # Peform checkpatch checks on pull requests only
8 exit 0
9 fi
10
11 # The below "set" is commented, because the checkpatch.pl returns 1 (error) for warnings too.
12 # And the rdma-core code is not mature enough to be warning safe
13 # set -e
14
15 if [ "x$TRAVIS_COMMIT_RANGE" != "x" ]; then
16 wget -q https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/scripts/checkpatch.pl \
17 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/scripts/spelling.txt
18 DIR_FOR_PATCHES_TO_CHECK=$(mktemp -d)
19 git format-patch --no-cover-letter $TRAVIS_COMMIT_RANGE ^$TRAVIS_BRANCH -o $DIR_FOR_PATCHES_TO_CHECK/
20 CHECKPATCH_OPT="--no-tree --ignore PREFER_KERNEL_TYPES,FILE_PATH_CHANGES,EXECUTE_PERMISSIONS,USE_NEGATIVE_ERRNO,CONST_STRUCT $DIR_FOR_PATCHES_TO_CHECK/*"
21 perl checkpatch.pl $CHECKPATCH_OPT
22 if [ $? -ne 0 ]; then
23 # We rerun checkpatch to simplify parsing and to understand if we failed for errors
24 # For example, the output on some arbitrary patchset of the following line without awk is:
25 # total: 1 errors, 3 warnings, 42 lines checked
26 NUMB_ERRRORS=$(perl checkpatch.pl --terse $CHECKPATCH_OPT | awk 'BEGIN {FS = "total:"} ; {sum+=$2} END {print sum}')
27 exit $NUMB_ERRRORS
28 fi
29 fi