From: Joe Perches on
I like the concept and believe the kernel tree is a better
repository for these scripts than an external website.

On Mon, 2010-04-26 at 23:11 +0200, Nicolas Palix wrote:
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 3d29fa3..2aab763 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1533,6 +1533,16 @@ L: platform-driver-x86(a)vger.kernel.org
> S: Supported
> F: drivers/platform/x86/classmate-laptop.c
>
> +COCCINELLE

COCCINELLE/Semantic Patches (SmPL)

> +coccicheck-context coccicheck-patch coccicheck-org coccicheck-report:
> + @echo "\nPlease, check for false positive in the output before submitting a patch.\n\n"\

Please check for false positives etc...

> + "Take particularly attention when using the \"patch\" mode\n"\
> + "and carefully review the patch YOU are about to submit.\n"

you



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Randy Dunlap on
Nicolas Palix wrote:

> diff --git a/Makefile b/Makefile
> index 67c1001..293c88b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1424,6 +1425,14 @@ versioncheck:
> -name '*.[hcS]' -type f -print | sort \
> | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
>
> +coccicheck-context coccicheck-patch coccicheck-org coccicheck-report:
> + @echo "\nPlease check for false positive in the output before submitting a patch.\n\n"\

positives

> + "Take particularly attention when using the \"patch\" mode\n"\

particular

> + "and carefully review the patch you are about to submit.\n"
> + @find $(srctree)/scripts/smpl/ \
> + -name '*.cocci' -type f \
> + -exec $(srctree)/scripts/spatch.sh $(SPATCH) $(@:coccicheck-%=%) \{} $(srctree) \;
> +
> namespacecheck:
> $(PERL) $(srctree)/scripts/namespace.pl
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Nicolas Palix on
On Monday 26 April 2010 23:37:01 Joe Perches wrote:
> I like the concept and believe the kernel tree is a better
> repository for these scripts than an external website.

Thank you for your feedback and support.

I attached an updated version of the patch 1/4.

>
> On Mon, 2010-04-26 at 23:11 +0200, Nicolas Palix wrote:
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 3d29fa3..2aab763 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -1533,6 +1533,16 @@ L: platform-driver-x86(a)vger.kernel.org
> > S: Supported
> > F: drivers/platform/x86/classmate-laptop.c
> >
> > +COCCINELLE
>
> COCCINELLE/Semantic Patches (SmPL)
>
> > +coccicheck-context coccicheck-patch coccicheck-org coccicheck-report:
> > + @echo "\nPlease, check for false positive in the output before submitting a patch.\n\n"\
>
> Please check for false positives etc...
>
> > + "Take particularly attention when using the \"patch\" mode\n"\
> > + "and carefully review the patch YOU are about to submit.\n"
>
> you
>
>
>
>
From 98aba248f7cba64c771f3632c11b8188819c45a1 Mon Sep 17 00:00:00 2001
From: Nicolas Palix <npalix(a)diku.dk>
Date: Sun, 4 Apr 2010 15:42:57 +0200
Subject: [PATCH 1/4] Add targets to use the Coccinelle checker

Four targets are added. Each one generates a different
output kind: context, patch, org, report.
Every SmPL file in 'scripts/smpl' is given to the spatch frontend
(located in the 'scripts' directory), and applied to the entire
source tree.

Signed-off-by: Nicolas Palix <npalix(a)diku.dk>
---
MAINTAINERS | 10 ++++++++++
Makefile | 9 +++++++++
scripts/spatch.sh | 14 ++++++++++++++
3 files changed, 33 insertions(+), 0 deletions(-)
create mode 100755 scripts/spatch.sh

diff --git a/MAINTAINERS b/MAINTAINERS
index 3d29fa3..2aab763 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1533,6 +1533,16 @@ L: platform-driver-x86(a)vger.kernel.org
S: Supported
F: drivers/platform/x86/classmate-laptop.c

+COCCINELLE/Semantic Patches (SmPL)
+M: Julia Lawall <julia(a)diku.dk>
+M: Gilles Muller <Gilles.Muller(a)lip6.fr>
+M: Nicolas Palix <npalix(a)diku.dk>
+L: cocci(a)diku.dk
+W: http://coccinelle.lip6.fr/
+S: Supported
+F: scripts/smpl/
+F: scripts/spatch.sh
+
CODA FILE SYSTEM
M: Jan Harkes <jaharkes(a)cs.cmu.edu>
M: coda(a)cs.cmu.edu
diff --git a/Makefile b/Makefile
index 67c1001..293c88b 100644
--- a/Makefile
+++ b/Makefile
@@ -325,6 +325,7 @@ INSTALLKERNEL := installkernel
DEPMOD = /sbin/depmod
KALLSYMS = scripts/kallsyms
PERL = perl
+SPATCH = spatch
CHECK = sparse

CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
@@ -1424,6 +1425,14 @@ versioncheck:
-name '*.[hcS]' -type f -print | sort \
| xargs $(PERL) -w $(srctree)/scripts/checkversion.pl

+coccicheck-context coccicheck-patch coccicheck-org coccicheck-report:
+ @echo "\nPlease check for false positive in the output before submitting a patch.\n\n"\
+ "Take particularly attention when using the \"patch\" mode\n"\
+ "and carefully review the patch you are about to submit.\n"
+ @find $(srctree)/scripts/smpl/ \
+ -name '*.cocci' -type f \
+ -exec $(srctree)/scripts/spatch.sh $(SPATCH) $(@:coccicheck-%=%) \{} $(srctree) \;
+
namespacecheck:
$(PERL) $(srctree)/scripts/namespace.pl

diff --git a/scripts/spatch.sh b/scripts/spatch.sh
new file mode 100755
index 0000000..bdcca15
--- /dev/null
+++ b/scripts/spatch.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+SPATCH="$1"
+MODE="$2"
+COCCI="$3"
+DIR="$4"
+
+OPT=`grep "Option" $COCCI | cut -d':' -f2`
+FILE=`echo $COCCI | sed "s|$DIR/||"`
+
+echo Processing `basename $COCCI` with \"$OPT\"
+echo Message example to submit a patch:
+grep "^///" $COCCI | sed "s|///||" | sed "s|THISFILE|$FILE|"
+$SPATCH -D $MODE -very_quiet -sp_file $COCCI $OPT -dir $DIR
--
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Michal Marek on
Hi Nicolas,

On 27.4.2010 00:20, Nicolas Palix wrote:
> Four targets are added. Each one generates a different
> output kind: context, patch, org, report.
> Every SmPL file in 'scripts/smpl' is given to the spatch frontend
> (located in the 'scripts' directory), and applied to the entire
> source tree.

Cool!


> Signed-off-by: Nicolas Palix <npalix(a)diku.dk>
> ---
> MAINTAINERS | 10 ++++++++++
> Makefile | 9 +++++++++
> scripts/spatch.sh | 14 ++++++++++++++
> 3 files changed, 33 insertions(+), 0 deletions(-)
> create mode 100755 scripts/spatch.sh
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 3d29fa3..2aab763 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1533,6 +1533,16 @@ L: platform-driver-x86(a)vger.kernel.org
> S: Supported
> F: drivers/platform/x86/classmate-laptop.c
>
> +COCCINELLE/Semantic Patches (SmPL)
> +M: Julia Lawall <julia(a)diku.dk>
> +M: Gilles Muller <Gilles.Muller(a)lip6.fr>
> +M: Nicolas Palix <npalix(a)diku.dk>
> +L: cocci(a)diku.dk
> +W: http://coccinelle.lip6.fr/
> +S: Supported
> +F: scripts/smpl/
> +F: scripts/spatch.sh
> +
> CODA FILE SYSTEM
> M: Jan Harkes <jaharkes(a)cs.cmu.edu>
> M: coda(a)cs.cmu.edu
> diff --git a/Makefile b/Makefile
> index 67c1001..293c88b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -325,6 +325,7 @@ INSTALLKERNEL := installkernel
> DEPMOD = /sbin/depmod
> KALLSYMS = scripts/kallsyms
> PERL = perl
> +SPATCH = spatch
> CHECK = sparse
>
> CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
> @@ -1424,6 +1425,14 @@ versioncheck:
> -name '*.[hcS]' -type f -print | sort \
> | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
>
> +coccicheck-context coccicheck-patch coccicheck-org coccicheck-report:
> + @echo "\nPlease check for false positive in the output before submitting a patch.\n\n"\
> + "Take particularly attention when using the \"patch\" mode\n"\
> + "and carefully review the patch you are about to submit.\n"

This should be echo -e in bash, but then it won't work in dash I guess.
So better use multiple echo commands. Also please add the targets to
'make help' text and add coccicheck-% to the no-dot-config-targets variable.


> + @find $(srctree)/scripts/smpl/ \
> + -name '*.cocci' -type f \
> + -exec $(srctree)/scripts/spatch.sh $(SPATCH) $(@:coccicheck-%=%) \{} $(srctree) \;
> +

Please use 'for file in $(srctree)/scripts/smpl/*.cocci; do ...', so
that the reports are in a defined order. Or do you plan to use
subdirectories below scripts/smpl?


> namespacecheck:
> $(PERL) $(srctree)/scripts/namespace.pl
>
> diff --git a/scripts/spatch.sh b/scripts/spatch.sh
> new file mode 100755
> index 0000000..bdcca15
> --- /dev/null
> +++ b/scripts/spatch.sh
> @@ -0,0 +1,14 @@
> +#!/bin/sh
> +
> +SPATCH="$1"
> +MODE="$2"
> +COCCI="$3"
> +DIR="$4"
> +
> +OPT=`grep "Option" $COCCI | cut -d':' -f2`
> +FILE=`echo $COCCI | sed "s|$DIR/||"`
> +
> +echo Processing `basename $COCCI` with \"$OPT\"
> +echo Message example to submit a patch:
> +grep "^///" $COCCI | sed "s|///||" | sed "s|THISFILE|$FILE|"

echo "The semantic patch that makes this change is available"
echo "in $FILE"

Then you don't need to add the same comment to each of the *.cocci
files. Also is it necessary to advertise

"More information about semantic patching is available at
http://coccinelle.lip6.fr/"

before processing each *.cocci file? If you want the banner, you could
append it to the "Please check for false positives..." text printed once
in the beginning.


> +$SPATCH -D $MODE -very_quiet -sp_file $COCCI $OPT -dir $DIR

You can also print the URL here if the spatch command is not available.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Wolfram Sang on
On Mon, Apr 26, 2010 at 11:11:16PM +0200, Nicolas Palix wrote:
> Four targets are added. Each one generates a different
> output kind: context, patch, org, report.
> Every SmPL file in 'scripts/smpl' is given to the spatch frontend
> (located in the 'scripts' directory), and applied to the entire
> source tree.
>
> Signed-off-by: Nicolas Palix <npalix(a)diku.dk>
> ---
> MAINTAINERS | 10 ++++++++++
> Makefile | 9 +++++++++
> scripts/spatch.sh | 14 ++++++++++++++
> 3 files changed, 33 insertions(+), 0 deletions(-)
> create mode 100755 scripts/spatch.sh
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 3d29fa3..2aab763 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1533,6 +1533,16 @@ L: platform-driver-x86(a)vger.kernel.org
> S: Supported
> F: drivers/platform/x86/classmate-laptop.c
>
> +COCCINELLE
> +M: Julia Lawall <julia(a)diku.dk>
> +M: Gilles Muller <Gilles.Muller(a)lip6.fr>
> +M: Nicolas Palix <npalix(a)diku.dk>
> +L: cocci(a)diku.dk
> +W: http://coccinelle.lip6.fr/
> +S: Supported
> +F: scripts/smpl/
> +F: scripts/spatch.sh
> +
> CODA FILE SYSTEM
> M: Jan Harkes <jaharkes(a)cs.cmu.edu>
> M: coda(a)cs.cmu.edu
> diff --git a/Makefile b/Makefile
> index 67c1001..293c88b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -325,6 +325,7 @@ INSTALLKERNEL := installkernel
> DEPMOD = /sbin/depmod
> KALLSYMS = scripts/kallsyms
> PERL = perl
> +SPATCH = spatch
> CHECK = sparse
>
> CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
> @@ -1424,6 +1425,14 @@ versioncheck:
> -name '*.[hcS]' -type f -print | sort \
> | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
>
> +coccicheck-context coccicheck-patch coccicheck-org coccicheck-report:
> + @echo "\nPlease, check for false positive in the output before submitting a patch.\n\n"\
> + "Take particularly attention when using the \"patch\" mode\n"\
> + "and carefully review the patch YOU are about to submit.\n"
> + @find $(srctree)/scripts/smpl/ \
> + -name '*.cocci' -type f \
> + -exec $(srctree)/scripts/spatch.sh $(SPATCH) $(@:coccicheck-%=%) \{} $(srctree) \;
> +
> namespacecheck:
> $(PERL) $(srctree)/scripts/namespace.pl
>
> diff --git a/scripts/spatch.sh b/scripts/spatch.sh
> new file mode 100755
> index 0000000..bdcca15
> --- /dev/null
> +++ b/scripts/spatch.sh
> @@ -0,0 +1,14 @@
> +#!/bin/sh
> +
> +SPATCH="$1"
> +MODE="$2"
> +COCCI="$3"
> +DIR="$4"
> +
> +OPT=`grep "Option" $COCCI | cut -d':' -f2`
> +FILE=`echo $COCCI | sed "s|$DIR/||"`
> +
> +echo Processing `basename $COCCI` with \"$OPT\"
> +echo Message example to submit a patch:
> +grep "^///" $COCCI | sed "s|///||" | sed "s|THISFILE|$FILE|"

I think the part containing "THISFILE" the patches should be generated here at
runtime. Also, the grep-command can be done via sed.

> +$SPATCH -D $MODE -very_quiet -sp_file $COCCI $OPT -dir $DIR
> --
> 1.6.3.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo(a)vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |