* [PATCH V3] scripts: coccicheck: Do not use shift command when rule is specified
@ 2020-09-09 10:29 ` Sumera Priyadarsini
0 siblings, 0 replies; 3+ messages in thread
From: Sumera Priyadarsini @ 2020-09-09 10:29 UTC (permalink / raw)
To: cocci
Cc: linux-kernel, kernel-janitors, Gilles.Muller, Julia.Lawall,
masahiroy, nicolas.palix, michal.lkml
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 use the shift command only when
number of shell arguments is not zero.
Signed-off-by: Sumera Priyadarsini <sylphrenadin@gmail.com>
---
Changes in V2:
- Fix spelling errors as suggested by Markus Elfring
---
scripts/coccicheck | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/scripts/coccicheck b/scripts/coccicheck
index e04d328210ac..5c8df337e1e3 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -61,9 +61,19 @@ COCCIINCLUDE=${COCCIINCLUDE// -include/ --include}
if [ "$C" = "1" -o "$C" = "2" ]; then
ONLINE=1
- # Take only the last argument, which is the C file to test
- shift $(( $# - 1 ))
- OPTIONS="$COCCIINCLUDE $1"
+ # If the rule coccicheck is specified when calling make, number of
+ # arguments is zero
+ if [ $# -ne 0 ]; then
+ # Take only the last argument, which is the C file to test
+ shift $(( $# -1 ))
+ OPTIONS="$COCCIINCLUDE $1"
+ else
+ if [ "$KBUILD_EXTMOD" = "" ] ; then
+ OPTIONS="--dir $srctree $COCCIINCLUDE"
+ else
+ OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
+ fi
+ fi
# No need to parallelize Coccinelle since this mode takes one input file.
NPROC=1
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Cocci] [PATCH V3] scripts: coccicheck: Do not use shift command when rule is specified
@ 2020-09-09 10:29 ` Sumera Priyadarsini
0 siblings, 0 replies; 3+ messages in thread
From: Sumera Priyadarsini @ 2020-09-09 10:29 UTC (permalink / raw)
To: cocci
Cc: michal.lkml, Gilles.Muller, kernel-janitors, nicolas.palix,
linux-kernel, Julia.Lawall
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 use the shift command only when
number of shell arguments is not zero.
Signed-off-by: Sumera Priyadarsini <sylphrenadin@gmail.com>
---
Changes in V2:
- Fix spelling errors as suggested by Markus Elfring
---
scripts/coccicheck | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/scripts/coccicheck b/scripts/coccicheck
index e04d328210ac..5c8df337e1e3 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -61,9 +61,19 @@ COCCIINCLUDE=${COCCIINCLUDE// -include/ --include}
if [ "$C" = "1" -o "$C" = "2" ]; then
ONLINE=1
- # Take only the last argument, which is the C file to test
- shift $(( $# - 1 ))
- OPTIONS="$COCCIINCLUDE $1"
+ # If the rule coccicheck is specified when calling make, number of
+ # arguments is zero
+ if [ $# -ne 0 ]; then
+ # Take only the last argument, which is the C file to test
+ shift $(( $# -1 ))
+ OPTIONS="$COCCIINCLUDE $1"
+ else
+ if [ "$KBUILD_EXTMOD" = "" ] ; then
+ OPTIONS="--dir $srctree $COCCIINCLUDE"
+ else
+ OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
+ fi
+ fi
# No need to parallelize Coccinelle since this mode takes one input file.
NPROC=1
--
2.25.1
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH V3] scripts: coccicheck: Do not use shift command when rule is specified
@ 2020-09-09 10:29 ` Sumera Priyadarsini
0 siblings, 0 replies; 3+ messages in thread
From: Sumera Priyadarsini @ 2020-09-09 10:41 UTC (permalink / raw)
To: cocci
Cc: michal.lkml, Gilles.Muller, kernel-janitors, nicolas.palix,
linux-kernel, Julia.Lawall
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 use the shift command only when
number of shell arguments is not zero.
Signed-off-by: Sumera Priyadarsini <sylphrenadin@gmail.com>
---
Changes in V2:
- Fix spelling errors as suggested by Markus Elfring
---
scripts/coccicheck | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/scripts/coccicheck b/scripts/coccicheck
index e04d328210ac..5c8df337e1e3 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -61,9 +61,19 @@ COCCIINCLUDE=${COCCIINCLUDE// -include/ --include}
if [ "$C" = "1" -o "$C" = "2" ]; then
ONLINE=1
- # Take only the last argument, which is the C file to test
- shift $(( $# - 1 ))
- OPTIONS="$COCCIINCLUDE $1"
+ # If the rule coccicheck is specified when calling make, number of
+ # arguments is zero
+ if [ $# -ne 0 ]; then
+ # Take only the last argument, which is the C file to test
+ shift $(( $# -1 ))
+ OPTIONS="$COCCIINCLUDE $1"
+ else
+ if [ "$KBUILD_EXTMOD" = "" ] ; then
+ OPTIONS="--dir $srctree $COCCIINCLUDE"
+ else
+ OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
+ fi
+ fi
# No need to parallelize Coccinelle since this mode takes one input file.
NPROC=1
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-09 10:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09 10:29 [PATCH V3] scripts: coccicheck: Do not use shift command when rule is specified Sumera Priyadarsini
2020-09-09 10:41 ` Sumera Priyadarsini
2020-09-09 10:29 ` [Cocci] " Sumera Priyadarsini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.