Update coccinelle related files/information
Subsystems (2)
cover Update coccinelle related files/information
Nicolas Palix (6):
MAINTAINERS: Coccinelle: Update email address
Coccinelle: Update documentation
Coccinelle: Improve user information with a new kind of comment
Coccinelle: Use new comment format to explain kfree.cocci
Coccinelle: Add a new mode named 'chain'
Coccinelle: Use the -no_show_diff option for org and report mode
Documentation/coccinelle.txt | 42 +++++++++++++++++++++++++++++----- MAINTAINERS | 2 +- scripts/coccicheck | 30 +++++++++++++++++++----- scripts/coccinelle/free/kfree.cocci | 9 ++++--- 4 files changed, 64 insertions(+), 19 deletions(-)
PATCH 1/6 MAINTAINERS: Coccinelle: Update email address
Update my email address
--- MAINTAINERS | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
MAINTAINERS +1 -1
@@ -1479,7 +1479,7 @@ F: drivers/platform/x86/classmate-laptop.c COCCINELLE/Semantic Patches (SmPL) M: Julia Lawall <[email protected]> M: Gilles Muller <[email protected]> -M: Nicolas Palix <[email protected]> +M: Nicolas Palix <[email protected]> L: [email protected] (moderated for non-subscribers) W: http://coccinelle.lip6.fr/ S: Supported
Signature · 1 line
1.7.0.4
PATCH 2/6 Coccinelle: Update documentation
In reply to Nicolas Palix - Add information about use of the C={1,2} make flag
- Add a description of the new chain mode mechanism
- Add a link to the wiki
--- Documentation/coccinelle.txt | 42 +++++++++++++++++++++++++++++++++++------- 1 files changed, 35 insertions(+), 7 deletions(-)
Documentation/coccinelle.txt +35 -7
@@ -24,6 +24,9 @@ of many distributions, e.g. : You can get the latest version released from the Coccinelle homepage at http://coccinelle.lip6.fr/ +Information and tips about Coccinelle are also provided on the wiki +pages at http://cocci.ekstranet.diku.dk/wiki/doku.php + Once you have it, run the following command: ./configure
@@ -41,20 +44,22 @@ A Coccinelle-specific target is defined in the top level Makefile. This target is named 'coccicheck' and calls the 'coccicheck' front-end in the 'scripts' directory. -Four modes are defined: report, patch, context, and org. The mode to +Four modes are defined: patch, report, context, and org. The mode to use is specified by setting the MODE variable with 'MODE=<mode>'. +'patch' proposes a fix, when possible. + 'report' generates a list in the following format: file:line:column-column: message -'patch' proposes a fix, when possible. - 'context' highlights lines of interest and their context in a diff-like style.Lines of interest are indicated with '-'. 'org' generates a report in the Org mode format of Emacs. -Note that not all semantic patches implement all modes. +Note that not all semantic patches implement all modes. To easy use +of Coccinelle, the default mode is "chain" which tries the previous +modes in the order above until one successes. To make a report for every semantic patch, run the following command:
@@ -68,9 +73,9 @@ To produce patches, run: The coccicheck target applies every semantic patch available in the -subdirectories of 'scripts/coccinelle' to the entire Linux kernel. +sub-directories of 'scripts/coccinelle' to the entire Linux kernel. -For each semantic patch, a changelog message is proposed. It gives a +For each semantic patch, a commit message is proposed. It gives a description of the problem being checked by the semantic patch, and includes a reference to Coccinelle.
@@ -93,12 +98,35 @@ or make coccicheck COCCI=<my_SP.cocci> MODE=report + Using Coccinelle on (modified) files +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To apply Coccinelle on a file basis, instead of a directory basis, the +following command may be used: + + make C=1 CHECK="scripts/coccicheck" + +To check only newly edited code, use the value 2 for the C flag, i.e. + + make C=2 CHECK="scripts/coccicheck" + +This runs every semantic patch in scripts/coccinelle by default. The +COCCI variable may additionally be used to only apply a single +semantic patch as shown in the previous section. + +The "chain" mode is the default. You can select another one with the +MODE variable explained above. + +In this mode, there is no information about semantic patches +displayed, and no commit message proposed. + + Proposing new semantic patches ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ New semantic patches can be proposed and submitted by kernel developers. For sake of clarity, they should be organized in the -subdirectories of 'scripts/coccinelle/'. +sub-directories of 'scripts/coccinelle/'. Detailed description of the 'report' mode
Signature · 1 line
1.7.0.4
Re: [PATCH 2/6] Coccinelle: Update documentation
Quoted 6 lines · On Fri, 8 Oct 2010 21:27:37 +0200 Nicolas Palix wrote:
- Add information about use of the C={1,2} make flag
- Add a description of the new chain mode mechanism
- Add a link to the wikiSigned-off-by Nicolas Palix <[email protected]>Signed-off-by Julia Lawall <[email protected]>
Michal,
I guess that you will merge this one with the other Coccinelle patches?
Thanks.
Nicolas, please see comments below.
Quoted 30 lines
--- Documentation/coccinelle.txt | 42 +++++++++++++++++++++++++++++++++++------- 1 files changed, 35 insertions(+), 7 deletions(-)Documentation/coccinelle.txt +6
-1@@ -24,6 +24,9 @@ of many distributions, e.g. : You can get the latest version released from the Coccinelle homepage at http://coccinelle.lip6.fr/ +Information and tips about Coccinelle are also provided on the wiki +pages at http://cocci.ekstranet.diku.dk/wiki/doku.php + Once you have it, run the following command: ./configure@@ -41,20 +44,22 @@ A Coccinelle-specific target is defined in the top level Makefile. This target is named 'coccicheck' and calls the 'coccicheck' front-end in the 'scripts' directory. -Four modes are defined: report, patch, context, and org. The mode to +Four modes are defined: patch, report, context, and org. The mode to use is specified by setting the MODE variable with 'MODE=<mode>'. +'patch' proposes a fix, when possible. + 'report' generates a list in the following format: file:line:column-column: message
Documentation/coccinelle.txt A Coccinelle-specific target is defined in the top level · line 60
Quoted 10 lines
Documentation/coccinelle.txt +1
-3-'patch' proposes a fix, when possible. - 'context' highlights lines of interest and their context in a diff-like style.Lines of interest are indicated with '-'. 'org' generates a report in the Org mode format of Emacs. -Note that not all semantic patches implement all modes. +Note that not all semantic patches implement all modes. To easy use
For easy use
Documentation/coccinelle.txt A Coccinelle-specific target is defined in the top level · line 62
Quoted 2 lines
Documentation/coccinelle.txt +2
-0+of Coccinelle, the default mode is "chain" which tries the previous +modes in the order above until one successes.
until one succeeds.
Also, please drop trailing spaces.
Quoted 43 lines
Documentation/coccinelle.txt +25
-2To make a report for every semantic patch, run the following command:@@ -68,9 +73,9 @@ To produce patches, run: The coccicheck target applies every semantic patch available in the -subdirectories of 'scripts/coccinelle' to the entire Linux kernel. +sub-directories of 'scripts/coccinelle' to the entire Linux kernel. -For each semantic patch, a changelog message is proposed. It gives a +For each semantic patch, a commit message is proposed. It gives a description of the problem being checked by the semantic patch, and includes a reference to Coccinelle.@@ -93,12 +98,35 @@ or make coccicheck COCCI=<my_SP.cocci> MODE=report + Using Coccinelle on (modified) files +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To apply Coccinelle on a file basis, instead of a directory basis, the +following command may be used: + + make C=1 CHECK="scripts/coccicheck" + +To check only newly edited code, use the value 2 for the C flag, i.e. + + make C=2 CHECK="scripts/coccicheck" + +This runs every semantic patch in scripts/coccinelle by default. The +COCCI variable may additionally be used to only apply a single +semantic patch as shown in the previous section. + +The "chain" mode is the default. You can select another one with the +MODE variable explained above. + +In this mode, there is no information about semantic patches +displayed, and no commit message proposed. + +
Documentation/coccinelle.txt or · line 132
Quoted 10 lines
Documentation/coccinelle.txt +1
-1Proposing new semantic patches ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ New semantic patches can be proposed and submitted by kernel developers. For sake of clarity, they should be organized in the -subdirectories of 'scripts/coccinelle/'. +sub-directories of 'scripts/coccinelle/'. Detailed description of the 'report' mode
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
Re: [PATCH 2/6] Coccinelle: Update documentation
- Add information about use of the C={1,2} make flag
- Add a description of the new chain mode mechanism
- Add a link to the wiki
---
This is a resubmission that fixes trailing whitespaces and a typo.
Documentation/coccinelle.txt | 42 +++++++++++++++++++++++++++++++++++------- 1 files changed, 35 insertions(+), 7 deletions(-)
Documentation/coccinelle.txt +35 -7
@@ -24,6 +24,9 @@ of many distributions, e.g. : You can get the latest version released from the Coccinelle homepage at http://coccinelle.lip6.fr/ +Information and tips about Coccinelle are also provided on the wiki +pages at http://cocci.ekstranet.diku.dk/wiki/doku.php + Once you have it, run the following command: ./configure
@@ -41,20 +44,22 @@ A Coccinelle-specific target is defined in the top level Makefile. This target is named 'coccicheck' and calls the 'coccicheck' front-end in the 'scripts' directory. -Four modes are defined: report, patch, context, and org. The mode to +Four modes are defined: patch, report, context, and org. The mode to use is specified by setting the MODE variable with 'MODE=<mode>'. +'patch' proposes a fix, when possible. + 'report' generates a list in the following format: file:line:column-column: message -'patch' proposes a fix, when possible. - 'context' highlights lines of interest and their context in a diff-like style.Lines of interest are indicated with '-'. 'org' generates a report in the Org mode format of Emacs. -Note that not all semantic patches implement all modes. +Note that not all semantic patches implement all modes. For easy use +of Coccinelle, the default mode is "chain" which tries the previous +modes in the order above until one succeeds. To make a report for every semantic patch, run the following command:
@@ -68,9 +73,9 @@ To produce patches, run: The coccicheck target applies every semantic patch available in the -subdirectories of 'scripts/coccinelle' to the entire Linux kernel. +sub-directories of 'scripts/coccinelle' to the entire Linux kernel. -For each semantic patch, a changelog message is proposed. It gives a +For each semantic patch, a commit message is proposed. It gives a description of the problem being checked by the semantic patch, and includes a reference to Coccinelle.
@@ -93,12 +98,35 @@ or make coccicheck COCCI=<my_SP.cocci> MODE=report + Using Coccinelle on (modified) files +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To apply Coccinelle on a file basis, instead of a directory basis, the +following command may be used: + + make C=1 CHECK="scripts/coccicheck" + +To check only newly edited code, use the value 2 for the C flag, i.e. + + make C=2 CHECK="scripts/coccicheck" + +This runs every semantic patch in scripts/coccinelle by default. The +COCCI variable may additionally be used to only apply a single +semantic patch as shown in the previous section. + +The "chain" mode is the default. You can select another one with the +MODE variable explained above. + +In this mode, there is no information about semantic patches +displayed, and no commit message proposed. + + Proposing new semantic patches ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ New semantic patches can be proposed and submitted by kernel developers. For sake of clarity, they should be organized in the -subdirectories of 'scripts/coccinelle/'. +sub-directories of 'scripts/coccinelle/'. Detailed description of the 'report' mode
Re: [PATCH 2/6] Coccinelle: Update documentation
Quoted 6 lines · Nicolas Palix
- Add information about use of the C={1,2} make flag
- Add a description of the new chain mode mechanism
- Add a link to the wikiSigned-off-by Nicolas Palix <[email protected]>Signed-off-by Julia Lawall <[email protected]>
Thanks, I applied the whole series to kbuild-2.6.git#misc.
Michal
Quoted 96 lines
---
This is a resubmission that fixes trailing whitespaces and a typo.Documentation/coccinelle.txt | 42 +++++++++++++++++++++++++++++++++++------- 1 files changed, 35 insertions(+), 7 deletions(-)Documentation/coccinelle.txt +35
-7@@ -24,6 +24,9 @@ of many distributions, e.g. : You can get the latest version released from the Coccinelle homepage at http://coccinelle.lip6.fr/ +Information and tips about Coccinelle are also provided on the wiki +pages at http://cocci.ekstranet.diku.dk/wiki/doku.php + Once you have it, run the following command: ./configure@@ -41,20 +44,22 @@ A Coccinelle-specific target is defined in the top level Makefile. This target is named 'coccicheck' and calls the 'coccicheck' front-end in the 'scripts' directory. -Four modes are defined: report, patch, context, and org. The mode to +Four modes are defined: patch, report, context, and org. The mode to use is specified by setting the MODE variable with 'MODE=<mode>'. +'patch' proposes a fix, when possible. + 'report' generates a list in the following format: file:line:column-column: message -'patch' proposes a fix, when possible. - 'context' highlights lines of interest and their context in a diff-like style.Lines of interest are indicated with '-'. 'org' generates a report in the Org mode format of Emacs. -Note that not all semantic patches implement all modes. +Note that not all semantic patches implement all modes. For easy use +of Coccinelle, the default mode is "chain" which tries the previous +modes in the order above until one succeeds. To make a report for every semantic patch, run the following command:@@ -68,9 +73,9 @@ To produce patches, run: The coccicheck target applies every semantic patch available in the -subdirectories of 'scripts/coccinelle' to the entire Linux kernel. +sub-directories of 'scripts/coccinelle' to the entire Linux kernel. -For each semantic patch, a changelog message is proposed. It gives a +For each semantic patch, a commit message is proposed. It gives a description of the problem being checked by the semantic patch, and includes a reference to Coccinelle.@@ -93,12 +98,35 @@ or make coccicheck COCCI=<my_SP.cocci> MODE=report + Using Coccinelle on (modified) files +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To apply Coccinelle on a file basis, instead of a directory basis, the +following command may be used: + + make C=1 CHECK="scripts/coccicheck" + +To check only newly edited code, use the value 2 for the C flag, i.e. + + make C=2 CHECK="scripts/coccicheck" + +This runs every semantic patch in scripts/coccinelle by default. The +COCCI variable may additionally be used to only apply a single +semantic patch as shown in the previous section. + +The "chain" mode is the default. You can select another one with the +MODE variable explained above. + +In this mode, there is no information about semantic patches +displayed, and no commit message proposed. + + Proposing new semantic patches ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ New semantic patches can be proposed and submitted by kernel developers. For sake of clarity, they should be organized in the -subdirectories of 'scripts/coccinelle/'. +sub-directories of 'scripts/coccinelle/'. Detailed description of the 'report' mode
PATCH 3/6 Coccinelle: Improve user information with a new kind of comment
In reply to Nicolas PalixImprove user information with a new kind of comment about semantic patch output.
Fix spelling.
--- scripts/coccicheck | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
scripts/coccicheck +11 -3
@@ -25,7 +25,7 @@ fi if [ "$MODE" = "" ] ; then if [ "$ONLINE" = "0" ] ; then - echo 'You have not explicitly specify the mode to use. Fallback to "report".' + echo 'You have not explicitly specified the mode to use. Fallback to "report".' echo 'You can specify the mode with "make coccicheck MODE=<mode>"' echo 'Available modes are: report, patch, context, org' fi
@@ -52,10 +52,12 @@ coccinelle () { FILE=`echo $COCCI | sed "s|$srctree/||"` - echo "Processing `basename $COCCI` with option(s) \"$OPT\"" + echo "Processing `basename $COCCI`" + echo "with option(s) \"$OPT\"" + echo '' echo 'Message example to submit a patch:' - sed -e '/\/\/\//!d' -e 's|^///||' $COCCI + sed -ne 's|^///||p' $COCCI echo ' The semantic patch that makes this change is available' echo " in $FILE."
@@ -64,6 +66,12 @@ coccinelle () { echo ' http://coccinelle.lip6.fr/' echo '' + if [ "`sed -ne 's|^//#||p' $COCCI`" ] ; then + echo 'Semantic patch information:' + sed -ne 's|^//#||p' $COCCI + echo '' + fi + $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT -dir $srctree || exit 1 else $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1
Signature · 1 line
1.7.0.4
PATCH 4/6 Coccinelle: Use new comment format to explain kfree.cocci
In reply to Nicolas PalixUse new comment format to separate proposed commit message and information about generated false positives
--- scripts/coccinelle/free/kfree.cocci | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
scripts/coccinelle/free/kfree.cocci +5 -4
@@ -1,7 +1,8 @@ -/// Find a use after free. Values of variables may imply that some -/// execution paths are not possible, resulting in false positives. -/// Another source of false positives are macros such as -/// SCTP_DBG_OBJCNT_DEC that do not actually evaluate their argument +/// Find a use after free. +//# Values of variables may imply that some +//# execution paths are not possible, resulting in false positives. +//# Another source of false positives are macros such as +//# SCTP_DBG_OBJCNT_DEC that do not actually evaluate their argument /// // Confidence: Moderate // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
Signature · 1 line
1.7.0.4
PATCH 5/6 Coccinelle: Add a new mode named 'chain'
In reply to Nicolas Palixspatch now returns -1 when a virtual rule (given with -D on the command line) is not defined in the semantic patch.
Using this spatch feature, coccicheck is now
tries several modes by default, in the order:
patch, report, context, org
--- scripts/coccicheck | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-)
scripts/coccicheck +11 -5
@@ -16,6 +16,7 @@ if [ "$C" = "1" -o "$C" = "2" ]; then else ONLINE=0 FLAGS="-very_quiet" + OPTIONS="-dir $srctree" fi if [ ! -x "$SPATCH" ]; then
@@ -25,11 +26,11 @@ fi if [ "$MODE" = "" ] ; then if [ "$ONLINE" = "0" ] ; then - echo 'You have not explicitly specified the mode to use. Fallback to "report".' + echo 'You have not explicitly specified the mode to use. Using default "chain" mode.' + echo 'All available modes will be tried (in that order): patch, report, context, org' echo 'You can specify the mode with "make coccicheck MODE=<mode>"' - echo 'Available modes are: report, patch, context, org' fi - MODE="report" + MODE="chain" fi if [ "$ONLINE" = "0" ] ; then
@@ -71,10 +72,15 @@ coccinelle () { sed -ne 's|^//#||p' $COCCI echo '' fi + fi - $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT -dir $srctree || exit 1 + if [ "$MODE" = "chain" ] ; then + $SPATCH -D patch $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ + $SPATCH -D report $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ + $SPATCH -D context $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ + $SPATCH -D org $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 else - $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 + $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 fi }
Signature · 1 line
1.7.0.4
PATCH 6/6 Coccinelle: Use the -no_show_diff option for org and report mode
In reply to Nicolas PalixThis allows to write the semantic patches with code sharing for the matching parts.
--- scripts/coccicheck | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
scripts/coccicheck +6 -4
@@ -31,6 +31,8 @@ if [ "$MODE" = "" ] ; then echo 'You can specify the mode with "make coccicheck MODE=<mode>"' fi MODE="chain" +elif [ "$MODE" = "report" -o "$MODE" = "org" ] ; then + FLAGS="$FLAGS -no_show_diff" fi if [ "$ONLINE" = "0" ] ; then
@@ -75,10 +77,10 @@ coccinelle () { fi if [ "$MODE" = "chain" ] ; then - $SPATCH -D patch $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ - $SPATCH -D report $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ - $SPATCH -D context $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ - $SPATCH -D org $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 + $SPATCH -D patch $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ + $SPATCH -D report $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \ + $SPATCH -D context $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ + $SPATCH -D org $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1 else $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 fi
Signature · 1 line
1.7.0.4