Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e596c790 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6: (39 commits)
  Revert "namespace: add source file location exceptions"
  Coccinelle: Add contextual message
  Coccinelle: Fix documentation
  Coccinelle: Find doubled arguments to boolean or bit operators.
  Coccinelle: Find nested lock+irqsave functions that use the same flags variables.
  namespace: add source file location exceptions
  scripts/extract-ikconfig: add support for bzip2, lzma and lzo
  kbuild: check return value of asprintf()
  scripts/namespace.pl: improve to get more correct results
  scripts/namespace.pl: some bug fixes
  scripts/namespace.pl: update file exclusion list
  scripts/namespace.pl: fix wrong source path
  Coccinelle: Use the -no_show_diff option for org and report mode
  Coccinelle: Add a new mode named 'chain'
  Coccinelle: Use new comment format to explain kfree.cocci
  Coccinelle: Improve user information with a new kind of comment
  Coccinelle: Update documentation
  MAINTAINERS: Coccinelle: Update email address
  Documentation/kbuild: modules.txt cleanup
  Documentation/kbuild: major edit of modules.txt sections 5-8
  ...
parents 51399a39 9231d9e0
Loading
Loading
Loading
Loading
+39 −11
Original line number Diff line number Diff line
@@ -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
@@ -111,7 +139,7 @@ Example:

Running

	make coccicheck MODE=report COCCI=scripts/coccinelle/err_cast.cocci
	make coccicheck MODE=report COCCI=scripts/coccinelle/api/err_cast.cocci

will execute the following part of the SmPL script.

@@ -149,7 +177,7 @@ identified.
Example:

Running
	make coccicheck MODE=patch COCCI=scripts/coccinelle/err_cast.cocci
	make coccicheck MODE=patch COCCI=scripts/coccinelle/api/err_cast.cocci

will execute the following part of the SmPL script.

@@ -193,7 +221,7 @@ NOTE: The diff-like output generated is NOT an applicable patch. The
Example:

Running
	make coccicheck MODE=context COCCI=scripts/coccinelle/err_cast.cocci
	make coccicheck MODE=context COCCI=scripts/coccinelle/api/err_cast.cocci

will execute the following part of the SmPL script.

@@ -228,7 +256,7 @@ diff -u -p /home/user/linux/crypto/ctr.c /tmp/nothing
Example:

Running
	make coccicheck MODE=org COCCI=scripts/coccinelle/err_cast.cocci
	make coccicheck MODE=org COCCI=scripts/coccinelle/api/err_cast.cocci

will execute the following part of the SmPL script.

+361 −372

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -1613,7 +1613,7 @@ F: drivers/platform/x86/classmate-laptop.c
COCCINELLE/Semantic Patches (SmPL)
M:	Julia Lawall <julia@diku.dk>
M:	Gilles Muller <Gilles.Muller@lip6.fr>
M:	Nicolas Palix <npalix@diku.dk>
M:	Nicolas Palix <npalix.work@gmail.com>
L:	cocci@diku.dk (moderated for non-subscribers)
W:	http://coccinelle.lip6.fr/
S:	Supported
+4 −1
Original line number Diff line number Diff line
@@ -333,7 +333,10 @@ static void docsect(char *filename, char *line)
		if (*s == '\n')
			*s = '\0';

	asprintf(&s, "DOC: %s", line);
	if (asprintf(&s, "DOC: %s", line) < 0) {
		perror("asprintf");
		exit(1);
	}
	consume_symbol(s);
	free(s);

+36 −10
Original line number Diff line number Diff line
@@ -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,13 @@ 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. 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"
elif [ "$MODE" = "report" -o "$MODE" = "org" ] ; then
    FLAGS="$FLAGS -no_show_diff"
fi

if [ "$ONLINE" = "0" ] ; then
@@ -44,7 +47,7 @@ coccinelle () {

    OPT=`grep "Option" $COCCI | cut -d':' -f2`

#   The option '-parse_cocci' can be used to syntaxically check the SmPL files.
#   The option '-parse_cocci' can be used to syntactically check the SmPL files.
#
#    $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null

@@ -52,19 +55,42 @@ 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

	if [ "$MODE" = "patch" ] ; then
	    echo ' The semantic patch that makes this change is available'
	elif [ "$MODE" = "report" ] ; then
	    echo ' The semantic patch that makes this report is available'
	elif [ "$MODE" = "context" ] ; then
	    echo ' The semantic patch that spots this code is available'
	elif [ "$MODE" = "org" ] ; then
	    echo ' The semantic patch that makes this Org report is available'
	else
	    echo ' The semantic patch that makes this output is available'
	fi
	echo " in $FILE."
	echo ''
	echo ' More information about semantic patching is available at'
	echo ' http://coccinelle.lip6.fr/'
	echo ''

	$SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT -dir $srctree || exit 1
	if [ "`sed -ne 's|^//#||p' $COCCI`" ] ; then
	    echo 'Semantic patch information:'
	    sed -ne 's|^//#||p' $COCCI
	    echo ''
	fi
    fi

    if [ "$MODE" = "chain" ] ; then
	$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
Loading