Skip to content

Commit d8f6e5c

Browse files
SylfrenaJuliaLawall
authored andcommitted
scripts: coccicheck: Correct usage of make coccicheck
The command "make coccicheck C=1 CHECK=scripts/coccicheck" results in the error: ./scripts/coccicheck: line 65: -1: shift count out of range This happens because every time the C variable is specified, the shell arguments need to be "shifted" in order to take only the last argument, which is the C file to test. These shell arguments mostly comprise flags that have been set in the Makefile. However, when coccicheck is specified in the make command as a rule, the number of shell arguments is zero, thus passing the invalid value -1 to the shift command, resulting in an error. Modify coccicheck to print correct usage of make coccicheck so as to avoid the error. Signed-off-by: Sumera Priyadarsini <[email protected]> Signed-off-by: Julia Lawall <[email protected]>
1 parent d2ee844 commit d8f6e5c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

scripts/coccicheck

+12
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ COCCIINCLUDE=${COCCIINCLUDE// -include/ --include}
6060
if [ "$C" = "1" -o "$C" = "2" ]; then
6161
ONLINE=1
6262

63+
if [[ $# -le 0 ]]; then
64+
echo ''
65+
echo 'Specifying both the variable "C" and rule "coccicheck" in the make
66+
command results in a shift count error.'
67+
echo ''
68+
echo 'Try specifying "scripts/coccicheck" as a value for the CHECK variable instead.'
69+
echo ''
70+
echo 'Example: make C=2 CHECK=scripts/coccicheck drivers/net/ethernet/ethoc.o'
71+
echo ''
72+
exit 1
73+
fi
74+
6375
# Take only the last argument, which is the C file to test
6476
shift $(( $# - 1 ))
6577
OPTIONS="$COCCIINCLUDE $1"

0 commit comments

Comments
 (0)