Переглянути джерело

Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild

Pull coccinelle updates from Michal Marek:
 "The misc branch is reserved for Coccinelle this time:

   - 'report' is the default mode
   - MAINTAINERS update for Coccinelle
   - documentation udate
   - use new option format for spatch(1)
   - J=<n> variable to mimic make -j for coccicheck
   - check for missing pci_free_consistent() calls

  There are some patches for rpm-pkg and deb-pkg waiting for the
  3.12-rc1 merge window"

* 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild:
  Coccinelle: Update information about the minimal version required
  Coccinelle: Update the options used to the new option scheme
  scripts: Coccinelle script for pci_free_consistent()
  Coccinelle: Update the documentation
  Coccinelle: Update section of MAINTAINERS
  coccicheck: span checks across CPUs
  scripts/coccinelle: check for field address argument to kfree
  Coccinelle: Update the Coccinelle section of MAINTAINERS
  Coccinelle: Make 'report' the default mode
Linus Torvalds 12 роки тому
батько
коміт
ae92494930
37 змінених файлів з 215 додано та 75 видалено
  1. 39 24
      Documentation/coccinelle.txt
  2. 3 0
      MAINTAINERS
  3. 57 19
      scripts/coccicheck
  4. 1 1
      scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci
  5. 1 1
      scripts/coccinelle/api/alloc/kzalloc-simple.cocci
  6. 1 1
      scripts/coccinelle/api/d_find_alias.cocci
  7. 1 1
      scripts/coccinelle/api/devm_request_and_ioremap.cocci
  8. 1 1
      scripts/coccinelle/api/kstrdup.cocci
  9. 1 1
      scripts/coccinelle/api/memdup.cocci
  10. 1 1
      scripts/coccinelle/api/memdup_user.cocci
  11. 1 1
      scripts/coccinelle/api/ptr_ret.cocci
  12. 1 1
      scripts/coccinelle/api/simple_open.cocci
  13. 1 1
      scripts/coccinelle/free/devm_free.cocci
  14. 1 1
      scripts/coccinelle/free/kfree.cocci
  15. 32 0
      scripts/coccinelle/free/kfreeaddr.cocci
  16. 52 0
      scripts/coccinelle/free/pci_free_consistent.cocci
  17. 1 1
      scripts/coccinelle/iterators/fen.cocci
  18. 1 1
      scripts/coccinelle/iterators/itnull.cocci
  19. 1 1
      scripts/coccinelle/iterators/list_entry_update.cocci
  20. 1 1
      scripts/coccinelle/iterators/use_after_iter.cocci
  21. 1 1
      scripts/coccinelle/locks/call_kern.cocci
  22. 1 1
      scripts/coccinelle/locks/double_lock.cocci
  23. 1 1
      scripts/coccinelle/locks/flags.cocci
  24. 1 1
      scripts/coccinelle/locks/mini_lock.cocci
  25. 1 1
      scripts/coccinelle/misc/boolinit.cocci
  26. 1 1
      scripts/coccinelle/misc/cstptr.cocci
  27. 1 1
      scripts/coccinelle/misc/doubleinit.cocci
  28. 1 1
      scripts/coccinelle/misc/ifaddr.cocci
  29. 1 1
      scripts/coccinelle/misc/ifcol.cocci
  30. 1 1
      scripts/coccinelle/misc/noderef.cocci
  31. 1 1
      scripts/coccinelle/misc/orplus.cocci
  32. 1 1
      scripts/coccinelle/misc/warn.cocci
  33. 1 1
      scripts/coccinelle/null/eno.cocci
  34. 1 1
      scripts/coccinelle/null/kmerr.cocci
  35. 1 1
      scripts/coccinelle/tests/doublebitand.cocci
  36. 1 1
      scripts/coccinelle/tests/doubletest.cocci
  37. 1 1
      scripts/coccinelle/tests/odd_ptr_err.cocci

+ 39 - 24
Documentation/coccinelle.txt

@@ -6,15 +6,17 @@ Copyright 2010 Gilles Muller <Gilles.Muller@lip6.fr>
  Getting Coccinelle
  Getting Coccinelle
 ~~~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~~~
 
 
-The semantic patches included in the kernel use the 'virtual rule'
-feature which was introduced in Coccinelle version 0.1.11.
+The semantic patches included in the kernel use features and options
+which are provided by Coccinelle version 1.0.0-rc11 and above.
+Using earlier versions will fail as the option names used by
+the Coccinelle files and coccicheck have been updated.
 
 
-Coccinelle (>=0.2.0) is available through the package manager
+Coccinelle is available through the package manager
 of many distributions, e.g. :
 of many distributions, e.g. :
 
 
- - Debian (>=squeeze)
- - Fedora (>=13)
- - Ubuntu (>=10.04 Lucid Lynx)
+ - Debian
+ - Fedora
+ - Ubuntu
  - OpenSUSE
  - OpenSUSE
  - Arch Linux
  - Arch Linux
  - NetBSD
  - NetBSD
@@ -36,11 +38,6 @@ as a regular user, and install it with
 
 
         sudo make install
         sudo make install
 
 
-The semantic patches in the kernel will work best with Coccinelle version
-0.2.4 or later.  Using earlier versions may incur some parse errors in the
-semantic patch code, but any results that are obtained should still be
-correct.
-
  Using Coccinelle on the Linux kernel
  Using Coccinelle on the Linux kernel
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
@@ -48,7 +45,7 @@ A Coccinelle-specific target is defined in the top level
 Makefile. This target is named 'coccicheck' and calls the 'coccicheck'
 Makefile. This target is named 'coccicheck' and calls the 'coccicheck'
 front-end in the 'scripts' directory.
 front-end in the 'scripts' directory.
 
 
-Four modes are defined: patch, report, context, and org. The mode to
+Four basic modes are defined: patch, report, context, and org. The mode to
 use is specified by setting the MODE variable with 'MODE=<mode>'.
 use is specified by setting the MODE variable with 'MODE=<mode>'.
 
 
 'patch' proposes a fix, when possible.
 'patch' proposes a fix, when possible.
@@ -62,18 +59,24 @@ diff-like style.Lines of interest are indicated with '-'.
 'org' generates a report in the Org mode format of Emacs.
 'org' generates a report in the Org mode format of Emacs.
 
 
 Note that not all semantic patches implement all modes. For easy use
 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.
+of Coccinelle, the default mode is "report".
+
+Two other modes provide some common combinations of these modes.
 
 
-To make a report for every semantic patch, run the following command:
+'chain' tries the previous modes in the order above until one succeeds.
 
 
-	make coccicheck MODE=report
+'rep+ctxt' runs successively the report mode and the context mode.
+	   It should be used with the C option (described later)
+	   which checks the code on a file basis.
 
 
-NB: The 'report' mode is the default one.
+Examples:
+	To make a report for every semantic patch, run the following command:
 
 
-To produce patches, run:
+		make coccicheck MODE=report
 
 
-	make coccicheck MODE=patch
+	To produce patches, run:
+
+		make coccicheck MODE=patch
 
 
 
 
 The coccicheck target applies every semantic patch available in the
 The coccicheck target applies every semantic patch available in the
@@ -91,6 +94,11 @@ To enable verbose messages set the V= variable, for example:
 
 
    make coccicheck MODE=report V=1
    make coccicheck MODE=report V=1
 
 
+By default, coccicheck tries to run as parallel as possible. To change
+the parallelism, set the J= variable. For example, to run across 4 CPUs:
+
+   make coccicheck MODE=report J=4
+
 
 
  Using Coccinelle with a single semantic patch
  Using Coccinelle with a single semantic patch
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -124,26 +132,33 @@ To check only newly edited code, use the value 2 for the C flag, i.e.
 
 
     make C=2 CHECK="scripts/coccicheck"
     make C=2 CHECK="scripts/coccicheck"
 
 
+In these modes, which works on a file basis, there is no information
+about semantic patches displayed, and no commit message proposed.
+
 This runs every semantic patch in scripts/coccinelle by default. The
 This runs every semantic patch in scripts/coccinelle by default. The
 COCCI variable may additionally be used to only apply a single
 COCCI variable may additionally be used to only apply a single
 semantic patch as shown in the previous section.
 semantic patch as shown in the previous section.
 
 
-The "chain" mode is the default. You can select another one with the
+The "report" mode is the default. You can select another one with the
 MODE variable explained above.
 MODE variable explained above.
 
 
-In this mode, there is no information about semantic patches
-displayed, and no commit message proposed.
-
  Additional flags
  Additional flags
 ~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~
 
 
 Additional flags can be passed to spatch through the SPFLAGS
 Additional flags can be passed to spatch through the SPFLAGS
 variable.
 variable.
 
 
-    make SPFLAGS=--use_glimpse coccicheck
+    make SPFLAGS=--use-glimpse coccicheck
+    make SPFLAGS=--use-idutils coccicheck
 
 
 See spatch --help to learn more about spatch options.
 See spatch --help to learn more about spatch options.
 
 
+Note that the '--use-glimpse' and '--use-idutils' options
+require external tools for indexing the code. None of them is
+thus active by default. However, by indexing the code with
+one of these tools, and according to the cocci file used,
+spatch could proceed the entire code base more quickly.
+
  Proposing new semantic patches
  Proposing new semantic patches
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 

+ 3 - 0
MAINTAINERS

@@ -2135,9 +2135,12 @@ COCCINELLE/Semantic Patches (SmPL)
 M:	Julia Lawall <Julia.Lawall@lip6.fr>
 M:	Julia Lawall <Julia.Lawall@lip6.fr>
 M:	Gilles Muller <Gilles.Muller@lip6.fr>
 M:	Gilles Muller <Gilles.Muller@lip6.fr>
 M:	Nicolas Palix <nicolas.palix@imag.fr>
 M:	Nicolas Palix <nicolas.palix@imag.fr>
+M:	Michal Marek <mmarek@suse.cz>
 L:	cocci@systeme.lip6.fr (moderated for non-subscribers)
 L:	cocci@systeme.lip6.fr (moderated for non-subscribers)
+T:	git git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild.git misc
 W:	http://coccinelle.lip6.fr/
 W:	http://coccinelle.lip6.fr/
 S:	Supported
 S:	Supported
+F:	Documentation/coccinelle.txt
 F:	scripts/coccinelle/
 F:	scripts/coccinelle/
 F:	scripts/coccicheck
 F:	scripts/coccicheck
 
 

+ 57 - 19
scripts/coccicheck

@@ -1,17 +1,31 @@
 #!/bin/bash
 #!/bin/bash
 
 
+#
+# This script requires at least spatch
+# version 1.0.0-rc11.
+#
+
 SPATCH="`which ${SPATCH:=spatch}`"
 SPATCH="`which ${SPATCH:=spatch}`"
 
 
+trap kill_running SIGTERM SIGINT
+declare -a SPATCH_PID
+
 # The verbosity may be set by the environmental parameter V=
 # The verbosity may be set by the environmental parameter V=
 # as for example with 'make V=1 coccicheck'
 # as for example with 'make V=1 coccicheck'
 
 
 if [ -n "$V" -a "$V" != "0" ]; then
 if [ -n "$V" -a "$V" != "0" ]; then
-	VERBOSE=1
+	VERBOSE="$V"
 else
 else
 	VERBOSE=0
 	VERBOSE=0
 fi
 fi
 
 
-FLAGS="$SPFLAGS -very_quiet"
+if [ -z "$J" ]; then
+	NPROC=$(getconf _NPROCESSORS_ONLN)
+else
+	NPROC="$J"
+fi
+
+FLAGS="$SPFLAGS --very-quiet"
 
 
 # spatch only allows include directories with the syntax "-I include"
 # spatch only allows include directories with the syntax "-I include"
 # while gcc also allows "-Iinclude" and "-include include"
 # while gcc also allows "-Iinclude" and "-include include"
@@ -27,14 +41,14 @@ if [ "$C" = "1" -o "$C" = "2" ]; then
 else
 else
     ONLINE=0
     ONLINE=0
     if [ "$KBUILD_EXTMOD" = "" ] ; then
     if [ "$KBUILD_EXTMOD" = "" ] ; then
-        OPTIONS="-dir $srctree $COCCIINCLUDE"
+        OPTIONS="--dir $srctree $COCCIINCLUDE"
     else
     else
-        OPTIONS="-dir $KBUILD_EXTMOD $COCCIINCLUDE"
+        OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
     fi
     fi
 fi
 fi
 
 
 if [ "$KBUILD_EXTMOD" != "" ] ; then
 if [ "$KBUILD_EXTMOD" != "" ] ; then
-    OPTIONS="-patch $srctree $OPTIONS"
+    OPTIONS="--patch $srctree $OPTIONS"
 fi
 fi
 
 
 if [ ! -x "$SPATCH" ]; then
 if [ ! -x "$SPATCH" ]; then
@@ -44,13 +58,21 @@ fi
 
 
 if [ "$MODE" = "" ] ; then
 if [ "$MODE" = "" ] ; then
     if [ "$ONLINE" = "0" ] ; then
     if [ "$ONLINE" = "0" ] ; then
-	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 have not explicitly specified the mode to use. Using default "report" mode.'
+	echo 'Available modes are the following: patch, report, context, org'
 	echo 'You can specify the mode with "make coccicheck MODE=<mode>"'
 	echo 'You can specify the mode with "make coccicheck MODE=<mode>"'
+	echo 'Note however that some modes are not implemented by some semantic patches.'
+    fi
+    MODE="report"
+fi
+
+if [ "$MODE" = "chain" ] ; then
+    if [ "$ONLINE" = "0" ] ; then
+	echo 'You have selected the "chain" mode.'
+	echo 'All available modes will be tried (in that order): patch, report, context, org'
     fi
     fi
-    MODE="chain"
 elif [ "$MODE" = "report" -o "$MODE" = "org" ] ; then
 elif [ "$MODE" = "report" -o "$MODE" = "org" ] ; then
-    FLAGS="$FLAGS -no_show_diff"
+    FLAGS="$FLAGS --no-show-diff"
 fi
 fi
 
 
 if [ "$ONLINE" = "0" ] ; then
 if [ "$ONLINE" = "0" ] ; then
@@ -61,19 +83,35 @@ if [ "$ONLINE" = "0" ] ; then
 fi
 fi
 
 
 run_cmd() {
 run_cmd() {
+	local i
 	if [ $VERBOSE -ne 0 ] ; then
 	if [ $VERBOSE -ne 0 ] ; then
-		echo "Running: $@"
+		echo "Running ($NPROC in parallel): $@"
 	fi
 	fi
-	eval $@
+	for i in $(seq 0 $(( NPROC - 1)) ); do
+		eval "$@ --max $NPROC --index $i &"
+		SPATCH_PID[$i]=$!
+		if [ $VERBOSE -eq 2 ] ; then
+			echo "${SPATCH_PID[$i]} running"
+		fi
+	done
+	wait
 }
 }
 
 
+kill_running() {
+	for i in $(seq $(( NPROC - 1 )) ); do
+		if [ $VERBOSE -eq 2 ] ; then
+			echo "Killing ${SPATCH_PID[$i]}"
+		fi
+		kill ${SPATCH_PID[$i]} 2>/dev/null
+	done
+}
 
 
 coccinelle () {
 coccinelle () {
     COCCI="$1"
     COCCI="$1"
 
 
     OPT=`grep "Option" $COCCI | cut -d':' -f2`
     OPT=`grep "Option" $COCCI | cut -d':' -f2`
 
 
-#   The option '-parse_cocci' can be used to syntactically 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
 #    $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null
 
 
@@ -114,20 +152,20 @@ coccinelle () {
 
 
     if [ "$MODE" = "chain" ] ; then
     if [ "$MODE" = "chain" ] ; then
 	run_cmd $SPATCH -D patch   \
 	run_cmd $SPATCH -D patch   \
-		$FLAGS -sp_file $COCCI $OPT $OPTIONS               || \
+		$FLAGS --cocci-file $COCCI $OPT $OPTIONS               || \
 	run_cmd $SPATCH -D report  \
 	run_cmd $SPATCH -D report  \
-		$FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \
+		$FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff || \
 	run_cmd $SPATCH -D context \
 	run_cmd $SPATCH -D context \
-		$FLAGS -sp_file $COCCI $OPT $OPTIONS               || \
+		$FLAGS --cocci-file $COCCI $OPT $OPTIONS               || \
 	run_cmd $SPATCH -D org     \
 	run_cmd $SPATCH -D org     \
-		$FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1
+		$FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff || exit 1
     elif [ "$MODE" = "rep+ctxt" ] ; then
     elif [ "$MODE" = "rep+ctxt" ] ; then
 	run_cmd $SPATCH -D report  \
 	run_cmd $SPATCH -D report  \
-		$FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff && \
+		$FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff && \
 	run_cmd $SPATCH -D context \
 	run_cmd $SPATCH -D context \
-		$FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1
+		$FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit 1
     else
     else
-	run_cmd $SPATCH -D $MODE   $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1
+	run_cmd $SPATCH -D $MODE   $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit 1
     fi
     fi
 
 
 }
 }

+ 1 - 1
scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci

@@ -5,7 +5,7 @@
 // Confidence: High
 // Confidence: High
 // Copyright: 2009,2010 Nicolas Palix, DIKU.  GPLv2.
 // Copyright: 2009,2010 Nicolas Palix, DIKU.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 //
 //
 // Keywords: kmalloc, kzalloc, kcalloc
 // Keywords: kmalloc, kzalloc, kcalloc
 // Version min: < 2.6.12 kmalloc
 // Version min: < 2.6.12 kmalloc

+ 1 - 1
scripts/coccinelle/api/alloc/kzalloc-simple.cocci

@@ -9,7 +9,7 @@
 // Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU.  GPLv2.
 // Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU.  GPLv2.
 // Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/rules/kzalloc.html
 // URL: http://coccinelle.lip6.fr/rules/kzalloc.html
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 //
 //
 // Keywords: kmalloc, kzalloc
 // Keywords: kmalloc, kzalloc
 // Version min: < 2.6.12 kmalloc
 // Version min: < 2.6.12 kmalloc

+ 1 - 1
scripts/coccinelle/api/d_find_alias.cocci

@@ -4,7 +4,7 @@
 //
 //
 // Confidence: Moderate
 // Confidence: Moderate
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
-// Options: -include_headers
+// Options: --include-headers
 
 
 virtual context
 virtual context
 virtual org
 virtual org

+ 1 - 1
scripts/coccinelle/api/devm_request_and_ioremap.cocci

@@ -10,7 +10,7 @@
 // Copyright: (C) 2011 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2011 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual patch
 virtual patch
 virtual org
 virtual org

+ 1 - 1
scripts/coccinelle/api/kstrdup.cocci

@@ -6,7 +6,7 @@
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual patch
 virtual patch
 virtual context
 virtual context

+ 1 - 1
scripts/coccinelle/api/memdup.cocci

@@ -6,7 +6,7 @@
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual patch
 virtual patch
 virtual context
 virtual context

+ 1 - 1
scripts/coccinelle/api/memdup_user.cocci

@@ -7,7 +7,7 @@
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual patch
 virtual patch
 virtual context
 virtual context

+ 1 - 1
scripts/coccinelle/api/ptr_ret.cocci

@@ -5,7 +5,7 @@
 // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.  GPLv2.
 // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.  GPLv2.
 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 //
 //
 // Keywords: ERR_PTR, PTR_ERR, PTR_RET
 // Keywords: ERR_PTR, PTR_ERR, PTR_RET
 // Version min: 2.6.39
 // Version min: 2.6.39

+ 1 - 1
scripts/coccinelle/api/simple_open.cocci

@@ -4,7 +4,7 @@
 ///
 ///
 // Confidence: High
 // Confidence: High
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual patch
 virtual patch
 virtual report
 virtual report

+ 1 - 1
scripts/coccinelle/free/devm_free.cocci

@@ -18,7 +18,7 @@
 // Copyright: (C) 2011 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2011 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual org
 virtual org
 virtual report
 virtual report

+ 1 - 1
scripts/coccinelle/free/kfree.cocci

@@ -10,7 +10,7 @@
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual org
 virtual org
 virtual report
 virtual report

+ 32 - 0
scripts/coccinelle/free/kfreeaddr.cocci

@@ -0,0 +1,32 @@
+/// Free of a structure field
+///
+// Confidence: High
+// Copyright: (C) 2013 Julia Lawall, INRIA/LIP6.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Comments:
+// Options: --no-includes --include-headers
+
+virtual org
+virtual report
+virtual context
+
+@r depends on context || report || org @
+expression e;
+identifier f;
+position p;
+@@
+
+* kfree@p(&e->f)
+
+@script:python depends on org@
+p << r.p;
+@@
+
+cocci.print_main("kfree",p)
+
+@script:python depends on report@
+p << r.p;
+@@
+
+msg = "ERROR: kfree of structure field"
+coccilib.report.print_report(p[0],msg)

+ 52 - 0
scripts/coccinelle/free/pci_free_consistent.cocci

@@ -0,0 +1,52 @@
+/// Find missing pci_free_consistent for every pci_alloc_consistent.
+///
+// Confidence: Moderate
+// Copyright: (C) 2013 Petr Strnad.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Keywords: pci_free_consistent, pci_alloc_consistent
+// Options: --no-includes --include-headers
+
+virtual report
+virtual org
+
+@search@
+local idexpression id;
+expression x,y,z,e;
+position p1,p2;
+type T;
+@@
+
+id = pci_alloc_consistent@p1(x,y,&z)
+... when != e = id
+if (id == NULL || ...) { ... return ...; }
+... when != pci_free_consistent(x,y,id,z)
+    when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
+    when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
+    when != e = (T)id
+    when exists
+(
+return 0;
+|
+return 1;
+|
+return id;
+|
+return@p2 ...;
+)
+
+@script:python depends on report@
+p1 << search.p1;
+p2 << search.p2;
+@@
+
+msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
+coccilib.report.print_report(p2[0],msg)
+
+@script:python depends on org@
+p1 << search.p1;
+p2 << search.p2;
+@@
+
+msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
+cocci.print_main(msg,p1)
+cocci.print_secs("",p2)

+ 1 - 1
scripts/coccinelle/iterators/fen.cocci

@@ -7,7 +7,7 @@
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual patch
 virtual patch
 virtual context
 virtual context

+ 1 - 1
scripts/coccinelle/iterators/itnull.cocci

@@ -11,7 +11,7 @@
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual patch
 virtual patch
 virtual context
 virtual context

+ 1 - 1
scripts/coccinelle/iterators/list_entry_update.cocci

@@ -9,7 +9,7 @@
 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual context
 virtual context
 virtual org
 virtual org

+ 1 - 1
scripts/coccinelle/iterators/use_after_iter.cocci

@@ -11,7 +11,7 @@
 // Copyright: (C) 2012 Gilles Muller, INRIA/LIP6.  GPLv2.
 // Copyright: (C) 2012 Gilles Muller, INRIA/LIP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual context
 virtual context
 virtual org
 virtual org

+ 1 - 1
scripts/coccinelle/locks/call_kern.cocci

@@ -9,7 +9,7 @@
 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual patch
 virtual patch
 virtual context
 virtual context

+ 1 - 1
scripts/coccinelle/locks/double_lock.cocci

@@ -8,7 +8,7 @@
 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual org
 virtual org
 virtual report
 virtual report

+ 1 - 1
scripts/coccinelle/locks/flags.cocci

@@ -6,7 +6,7 @@
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual context
 virtual context
 virtual org
 virtual org

+ 1 - 1
scripts/coccinelle/locks/mini_lock.cocci

@@ -11,7 +11,7 @@
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual context
 virtual context
 virtual org
 virtual org

+ 1 - 1
scripts/coccinelle/misc/boolinit.cocci

@@ -6,7 +6,7 @@
 // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.  GPLv2.
 // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.  GPLv2.
 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
-// Options: -include_headers
+// Options: --include-headers
 
 
 virtual patch
 virtual patch
 virtual context
 virtual context

+ 1 - 1
scripts/coccinelle/misc/cstptr.cocci

@@ -6,7 +6,7 @@
 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual org
 virtual org
 virtual report
 virtual report

+ 1 - 1
scripts/coccinelle/misc/doubleinit.cocci

@@ -8,7 +8,7 @@
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments: requires at least Coccinelle 0.2.4, lex or parse error otherwise
 // Comments: requires at least Coccinelle 0.2.4, lex or parse error otherwise
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual org
 virtual org
 virtual report
 virtual report

+ 1 - 1
scripts/coccinelle/misc/ifaddr.cocci

@@ -6,7 +6,7 @@
 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual org
 virtual org
 virtual report
 virtual report

+ 1 - 1
scripts/coccinelle/misc/ifcol.cocci

@@ -13,7 +13,7 @@
 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual org
 virtual org
 virtual report
 virtual report

+ 1 - 1
scripts/coccinelle/misc/noderef.cocci

@@ -6,7 +6,7 @@
 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual org
 virtual org
 virtual report
 virtual report

+ 1 - 1
scripts/coccinelle/misc/orplus.cocci

@@ -7,7 +7,7 @@
 // Copyright: (C) 2013 Gilles Muller, INRIA/LIP6.  GPLv2.
 // Copyright: (C) 2013 Gilles Muller, INRIA/LIP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual org
 virtual org
 virtual report
 virtual report

+ 1 - 1
scripts/coccinelle/misc/warn.cocci

@@ -5,7 +5,7 @@
 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual patch
 virtual patch
 virtual context
 virtual context

+ 1 - 1
scripts/coccinelle/null/eno.cocci

@@ -6,7 +6,7 @@
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual patch
 virtual patch
 virtual context
 virtual context

+ 1 - 1
scripts/coccinelle/null/kmerr.cocci

@@ -10,7 +10,7 @@
 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual context
 virtual context
 virtual org
 virtual org

+ 1 - 1
scripts/coccinelle/tests/doublebitand.cocci

@@ -10,7 +10,7 @@
 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual context
 virtual context
 virtual org
 virtual org

+ 1 - 1
scripts/coccinelle/tests/doubletest.cocci

@@ -8,7 +8,7 @@
 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual context
 virtual context
 virtual org
 virtual org

+ 1 - 1
scripts/coccinelle/tests/odd_ptr_err.cocci

@@ -7,7 +7,7 @@
 // Copyright: (C) 2012 Gilles Muller, INRIA.  GPLv2.
 // Copyright: (C) 2012 Gilles Muller, INRIA.  GPLv2.
 // URL: http://coccinelle.lip6.fr/
 // URL: http://coccinelle.lip6.fr/
 // Comments:
 // Comments:
-// Options: -no_includes -include_headers
+// Options: --no-includes --include-headers
 
 
 virtual patch
 virtual patch
 virtual context
 virtual context