2013-03-02 21:36:51

by Nicolas Palix (LIG)

[permalink] [raw]
Subject: [PATCH 1/4] Coccinelle: Restore coccicheck verbosity in ONLINE mode (C=1 or C=2)

A recent patch have introduce the VERBOSE variable and comments
now depend on it. However, the message printed for each cocci file
such not be printed when the ONLINE mode is active, whatever is
the value of VERBOSE.

Signed-off-by: Nicolas Palix <[email protected]>
---
scripts/coccicheck | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/coccicheck b/scripts/coccicheck
index 85d3189..7f0d6a6 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -72,7 +72,7 @@ coccinelle () {
#
# $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null

- if [ $VERBOSE -ne 0 ] ; then
+ if [ $VERBOSE -ne 0 -a $ONLINE -eq 0 ] ; then

FILE=`echo $COCCI | sed "s|$srctree/||"`

--
1.7.10.4


2013-03-02 21:36:57

by Nicolas Palix (LIG)

[permalink] [raw]
Subject: [PATCH 4/4] Coccinelle: Fix patch output when coccicheck is used with M= and C=

When the M variable is used, the -patch option should be given
to spatch. This patch fixes the case where C is used.

Signed-off-by: Nicolas Palix <[email protected]>
---
scripts/coccicheck | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/coccicheck b/scripts/coccicheck
index 6d492c0..06fcb33 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -29,10 +29,14 @@ else
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="-dir $srctree $COCCIINCLUDE"
else
- OPTIONS="-dir $KBUILD_EXTMOD -patch $srctree $COCCIINCLUDE"
+ OPTIONS="-dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
fi

+if [ "$KBUILD_EXTMOD" != "" ] ; then
+ OPTIONS="-patch $srctree $OPTIONS"
+fi
+
if [ ! -x "$SPATCH" ]; then
echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/'
exit 1
--
1.7.10.4

2013-03-02 21:36:55

by Nicolas Palix (LIG)

[permalink] [raw]
Subject: [PATCH 3/4] Coccinelle: Add support to the SPFLAGS variable

The SPFLAGS variable allows to pass additional options
to spatch, e.g. -use_glimpse.

Signed-off-by: Nicolas Palix <[email protected]>
---
Documentation/coccinelle.txt | 11 ++++++++++-
scripts/coccicheck | 2 +-
2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/Documentation/coccinelle.txt b/Documentation/coccinelle.txt
index dffa2d6..18de785 100644
--- a/Documentation/coccinelle.txt
+++ b/Documentation/coccinelle.txt
@@ -114,7 +114,7 @@ To apply Coccinelle to a specific directory, M= can be used.
For example, to check drivers/net/wireless/ one may write:

make coccicheck M=drivers/net/wireless/
-
+
To apply Coccinelle on a file basis, instead of a directory basis, the
following command may be used:

@@ -134,6 +134,15 @@ MODE variable explained above.
In this mode, there is no information about semantic patches
displayed, and no commit message proposed.

+ Additional flags
+~~~~~~~~~~~~~~~~~~
+
+Additional flags can be passed to spatch through the SPFLAGS
+variable.
+
+ make SPFLAGS=--use_glimpse coccicheck
+
+See spatch --help to learn more about spatch options.

Proposing new semantic patches
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/scripts/coccicheck b/scripts/coccicheck
index cdde8e0..6d492c0 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -11,7 +11,7 @@ else
VERBOSE=0
fi

-FLAGS="-very_quiet"
+FLAGS="$SPFLAGS -very_quiet"

# spatch only allows include directories with the syntax "-I include"
# while gcc also allows "-Iinclude" and "-include include"
--
1.7.10.4

2013-03-02 21:36:53

by Nicolas Palix (LIG)

[permalink] [raw]
Subject: [PATCH 2/4] Coccinelle: Cleanup the setting of the FLAGS and OPTIONS variables

The FLAGS variable is factorized independently of the ONLINE mode.
The OPTIONS variable is now based on LINUXINCLUDE and explicit
includes are thus removed.

The format of the -I option differs between gcc and spatch.
The COCCIINCLUDE is used to adapt the format. This rewritting
needs bash.

Signed-off-by: Nicolas Palix <[email protected]>
---
scripts/coccicheck | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/scripts/coccicheck b/scripts/coccicheck
index 7f0d6a6..cdde8e0 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash

SPATCH="`which ${SPATCH:=spatch}`"

@@ -11,24 +11,25 @@ else
VERBOSE=0
fi

+FLAGS="-very_quiet"
+
+# spatch only allows include directories with the syntax "-I include"
+# while gcc also allows "-Iinclude" and "-include include"
+COCCIINCLUDE=${LINUXINCLUDE//-I/-I }
+COCCIINCLUDE=${COCCIINCLUDE//-include/-I}
+
if [ "$C" = "1" -o "$C" = "2" ]; then
ONLINE=1

-# This requires Coccinelle >= 0.2.3
-# FLAGS="-ignore_unknown_options -very_quiet"
-# OPTIONS=$*
-
-# Workaround for Coccinelle < 0.2.3
- FLAGS="-I $srctree/include -very_quiet"
- shift $(( $# - 1 ))
- OPTIONS=$1
+ # Take only the last argument, which is the C file to test
+ shift $(( $# - 1 ))
+ OPTIONS="$COCCIINCLUDE $1"
else
ONLINE=0
- FLAGS="-very_quiet"
if [ "$KBUILD_EXTMOD" = "" ] ; then
- OPTIONS="-dir $srctree"
+ OPTIONS="-dir $srctree $COCCIINCLUDE"
else
- OPTIONS="-dir $KBUILD_EXTMOD -patch $srctree -I $srctree/include -I $KBUILD_EXTMOD/include"
+ OPTIONS="-dir $KBUILD_EXTMOD -patch $srctree $COCCIINCLUDE"
fi
fi

--
1.7.10.4

2013-04-08 13:52:44

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH 1/4] Coccinelle: Restore coccicheck verbosity in ONLINE mode (C=1 or C=2)

On 2.3.2013 22:36, Nicolas Palix wrote:
> A recent patch have introduce the VERBOSE variable and comments
> now depend on it. However, the message printed for each cocci file
> such not be printed when the ONLINE mode is active, whatever is
> the value of VERBOSE.
>
> Signed-off-by: Nicolas Palix <[email protected]>
> ---
> scripts/coccicheck | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

I applied these four to kbuild.git#misc.

Michal