2016-08-09 01:03:14 +03:00
|
|
|
.. Copyright 2010 Nicolas Palix <npalix@diku.dk>
|
|
|
|
.. Copyright 2010 Julia Lawall <julia@diku.dk>
|
|
|
|
.. Copyright 2010 Gilles Muller <Gilles.Muller@lip6.fr>
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
.. highlight:: none
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2018-11-21 03:35:19 +03:00
|
|
|
.. _devtools_coccinelle:
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Coccinelle
|
|
|
|
==========
|
|
|
|
|
|
|
|
Coccinelle is a tool for pattern matching and text transformation that has
|
|
|
|
many uses in kernel development, including the application of complex,
|
|
|
|
tree-wide patches and detection of problematic programming patterns.
|
|
|
|
|
|
|
|
Getting Coccinelle
|
2020-06-05 06:04:05 +03:00
|
|
|
------------------
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2013-07-03 18:41:01 +04:00
|
|
|
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.
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2013-07-03 18:41:01 +04:00
|
|
|
Coccinelle is available through the package manager
|
2010-06-06 19:15:02 +04:00
|
|
|
of many distributions, e.g. :
|
|
|
|
|
2013-07-03 18:41:01 +04:00
|
|
|
- Debian
|
|
|
|
- Fedora
|
|
|
|
- Ubuntu
|
2010-06-06 19:15:02 +04:00
|
|
|
- OpenSUSE
|
|
|
|
- Arch Linux
|
|
|
|
- NetBSD
|
|
|
|
- FreeBSD
|
|
|
|
|
2018-08-13 13:46:38 +03:00
|
|
|
Some distribution packages are obsolete and it is recommended
|
|
|
|
to use the latest version released from the Coccinelle homepage at
|
2010-06-06 19:15:02 +04:00
|
|
|
http://coccinelle.lip6.fr/
|
|
|
|
|
2018-08-13 13:46:38 +03:00
|
|
|
Or from Github at:
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2018-08-13 13:46:38 +03:00
|
|
|
https://github.com/coccinelle/coccinelle
|
|
|
|
|
|
|
|
Once you have it, run the following commands::
|
|
|
|
|
|
|
|
./autogen
|
|
|
|
./configure
|
2010-06-06 19:15:02 +04:00
|
|
|
make
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
as a regular user, and install it with::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
|
|
|
sudo make install
|
|
|
|
|
2018-08-13 13:46:38 +03:00
|
|
|
More detailed installation instructions to build from source can be
|
|
|
|
found at:
|
|
|
|
|
|
|
|
https://github.com/coccinelle/coccinelle/blob/master/install.txt
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Supplemental documentation
|
2020-06-05 06:04:05 +03:00
|
|
|
--------------------------
|
2016-06-30 01:14:58 +03:00
|
|
|
|
|
|
|
For supplemental documentation refer to the wiki:
|
|
|
|
|
|
|
|
https://bottest.wiki.kernel.org/coccicheck
|
|
|
|
|
|
|
|
The wiki documentation always refers to the linux-next version of the script.
|
|
|
|
|
2018-08-13 13:46:38 +03:00
|
|
|
For Semantic Patch Language(SmPL) grammar documentation refer to:
|
|
|
|
|
|
|
|
http://coccinelle.lip6.fr/documentation.php
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Using Coccinelle on the Linux kernel
|
|
|
|
------------------------------------
|
2010-06-06 19:15:02 +04:00
|
|
|
|
|
|
|
A Coccinelle-specific target is defined in the top level
|
2016-08-09 01:03:14 +03:00
|
|
|
Makefile. This target is named ``coccicheck`` and calls the ``coccicheck``
|
|
|
|
front-end in the ``scripts`` directory.
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Four basic modes are defined: ``patch``, ``report``, ``context``, and
|
|
|
|
``org``. The mode to use is specified by setting the MODE variable with
|
|
|
|
``MODE=<mode>``.
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
- ``patch`` proposes a fix, when possible.
|
2010-10-13 02:49:07 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
- ``report`` generates a list in the following format:
|
2010-06-06 19:15:02 +04:00
|
|
|
file:line:column-column: message
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
- ``context`` highlights lines of interest and their context in a
|
2020-07-01 22:17:32 +03:00
|
|
|
diff-like style. Lines of interest are indicated with ``-``.
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
- ``org`` generates a report in the Org mode format of Emacs.
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2010-10-13 02:49:07 +04:00
|
|
|
Note that not all semantic patches implement all modes. For easy use
|
2013-06-20 16:00:19 +04:00
|
|
|
of Coccinelle, the default mode is "report".
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2013-06-20 16:00:19 +04:00
|
|
|
Two other modes provide some common combinations of these modes.
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
- ``chain`` tries the previous modes in the order above until one succeeds.
|
|
|
|
|
|
|
|
- ``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.
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Examples
|
|
|
|
~~~~~~~~
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
To make a report for every semantic patch, run the following command::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2013-06-20 16:00:19 +04:00
|
|
|
make coccicheck MODE=report
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
To produce patches, run::
|
2013-06-20 16:00:19 +04:00
|
|
|
|
|
|
|
make coccicheck MODE=patch
|
2010-06-06 19:15:02 +04:00
|
|
|
|
|
|
|
|
|
|
|
The coccicheck target applies every semantic patch available in the
|
2016-08-09 01:03:14 +03:00
|
|
|
sub-directories of ``scripts/coccinelle`` to the entire Linux kernel.
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2010-10-13 02:49:07 +04:00
|
|
|
For each semantic patch, a commit message is proposed. It gives a
|
2010-06-06 19:15:02 +04:00
|
|
|
description of the problem being checked by the semantic patch, and
|
|
|
|
includes a reference to Coccinelle.
|
|
|
|
|
2020-07-01 22:17:32 +03:00
|
|
|
As with any static code analyzer, Coccinelle produces false
|
2010-06-06 19:15:02 +04:00
|
|
|
positives. Thus, reports must be carefully checked, and patches
|
|
|
|
reviewed.
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
To enable verbose messages set the V= variable, for example::
|
2013-01-29 20:03:37 +04:00
|
|
|
|
|
|
|
make coccicheck MODE=report V=1
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Coccinelle parallelization
|
2020-06-05 06:04:05 +03:00
|
|
|
--------------------------
|
coccicheck: enable parmap support
Coccinelle has had parmap support since 1.0.2, this means
it supports --jobs, enabling built-in multithreaded functionality,
instead of needing one to script it out. Just look for --jobs
in the help output to determine if this is supported and use it
only if your number of processors detected is > 1.
If parmap is enabled also enable the load balancing to be dynamic, so
that if a thread finishes early we keep feeding it.
stderr is currently sent to /dev/null, addressing a way to capture
that will be addressed next.
If --jobs is not supported we fallback to the old mechanism.
We expect to deprecate the old mechanism as soon as we can get
confirmation all users are ready.
While at it propagate back into the shell script any coccinelle error
code. When used in serialized mode where all cocci files are run this
also stops processing if an error has occured. This lets us handle some
errors in coccinelle cocci files and if they bail out we should inspect
the errors. This will be more useful later to help annotate coccinelle
version dependency requirements. This will let you run only SmPL files
that your system supports.
Extend Documentation/coccinelle.txt as well.
As a small example, prior to this change, on an 8-core system:
Before:
$ export COCCI=scripts/coccinelle/free/kfree.cocci
$ time make coccicheck MODE=report
...
real 29m14.912s
user 103m1.796s
sys 0m4.464s
After:
real 16m22.435s
user 128m30.060s
sys 0m2.712s
v4:
o expand Documentation/coccinelle.txt to reflect parmap support info
o update commit log to reflect what we actually do now with stderr
o split out DEBUG_FILE use into another patch
o detect number of CPUs and if its 1 then skip parmap support,
note that if you still support parmap, but have 1 CPU you will
also go through the new branches, so the old complex multithreaded process
is skipped as well.
v3:
o move USE_JOBS to avoid being overriden
v2:
o redirect coccinelle stderr to /dev/null by default and
only if DEBUG_FILE is used do we pass it to a file
o fix typo of paramap/parmap
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Nicolas Palix <nicolas.palix@imag.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:53 +03:00
|
|
|
|
2013-06-19 01:49:29 +04:00
|
|
|
By default, coccicheck tries to run as parallel as possible. To change
|
2016-08-09 01:03:14 +03:00
|
|
|
the parallelism, set the J= variable. For example, to run across 4 CPUs::
|
2013-06-19 01:49:29 +04:00
|
|
|
|
|
|
|
make coccicheck MODE=report J=4
|
|
|
|
|
2020-07-01 22:17:32 +03:00
|
|
|
As of Coccinelle 1.0.2 Coccinelle uses Ocaml parmap for parallelization;
|
coccicheck: enable parmap support
Coccinelle has had parmap support since 1.0.2, this means
it supports --jobs, enabling built-in multithreaded functionality,
instead of needing one to script it out. Just look for --jobs
in the help output to determine if this is supported and use it
only if your number of processors detected is > 1.
If parmap is enabled also enable the load balancing to be dynamic, so
that if a thread finishes early we keep feeding it.
stderr is currently sent to /dev/null, addressing a way to capture
that will be addressed next.
If --jobs is not supported we fallback to the old mechanism.
We expect to deprecate the old mechanism as soon as we can get
confirmation all users are ready.
While at it propagate back into the shell script any coccinelle error
code. When used in serialized mode where all cocci files are run this
also stops processing if an error has occured. This lets us handle some
errors in coccinelle cocci files and if they bail out we should inspect
the errors. This will be more useful later to help annotate coccinelle
version dependency requirements. This will let you run only SmPL files
that your system supports.
Extend Documentation/coccinelle.txt as well.
As a small example, prior to this change, on an 8-core system:
Before:
$ export COCCI=scripts/coccinelle/free/kfree.cocci
$ time make coccicheck MODE=report
...
real 29m14.912s
user 103m1.796s
sys 0m4.464s
After:
real 16m22.435s
user 128m30.060s
sys 0m2.712s
v4:
o expand Documentation/coccinelle.txt to reflect parmap support info
o update commit log to reflect what we actually do now with stderr
o split out DEBUG_FILE use into another patch
o detect number of CPUs and if its 1 then skip parmap support,
note that if you still support parmap, but have 1 CPU you will
also go through the new branches, so the old complex multithreaded process
is skipped as well.
v3:
o move USE_JOBS to avoid being overriden
v2:
o redirect coccinelle stderr to /dev/null by default and
only if DEBUG_FILE is used do we pass it to a file
o fix typo of paramap/parmap
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Nicolas Palix <nicolas.palix@imag.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:53 +03:00
|
|
|
if support for this is detected you will benefit from parmap parallelization.
|
|
|
|
|
|
|
|
When parmap is enabled coccicheck will enable dynamic load balancing by using
|
2020-07-01 22:17:32 +03:00
|
|
|
``--chunksize 1`` argument. This ensures we keep feeding threads with work
|
coccicheck: enable parmap support
Coccinelle has had parmap support since 1.0.2, this means
it supports --jobs, enabling built-in multithreaded functionality,
instead of needing one to script it out. Just look for --jobs
in the help output to determine if this is supported and use it
only if your number of processors detected is > 1.
If parmap is enabled also enable the load balancing to be dynamic, so
that if a thread finishes early we keep feeding it.
stderr is currently sent to /dev/null, addressing a way to capture
that will be addressed next.
If --jobs is not supported we fallback to the old mechanism.
We expect to deprecate the old mechanism as soon as we can get
confirmation all users are ready.
While at it propagate back into the shell script any coccinelle error
code. When used in serialized mode where all cocci files are run this
also stops processing if an error has occured. This lets us handle some
errors in coccinelle cocci files and if they bail out we should inspect
the errors. This will be more useful later to help annotate coccinelle
version dependency requirements. This will let you run only SmPL files
that your system supports.
Extend Documentation/coccinelle.txt as well.
As a small example, prior to this change, on an 8-core system:
Before:
$ export COCCI=scripts/coccinelle/free/kfree.cocci
$ time make coccicheck MODE=report
...
real 29m14.912s
user 103m1.796s
sys 0m4.464s
After:
real 16m22.435s
user 128m30.060s
sys 0m2.712s
v4:
o expand Documentation/coccinelle.txt to reflect parmap support info
o update commit log to reflect what we actually do now with stderr
o split out DEBUG_FILE use into another patch
o detect number of CPUs and if its 1 then skip parmap support,
note that if you still support parmap, but have 1 CPU you will
also go through the new branches, so the old complex multithreaded process
is skipped as well.
v3:
o move USE_JOBS to avoid being overriden
v2:
o redirect coccinelle stderr to /dev/null by default and
only if DEBUG_FILE is used do we pass it to a file
o fix typo of paramap/parmap
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Nicolas Palix <nicolas.palix@imag.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:53 +03:00
|
|
|
one by one, so that we avoid the situation where most work gets done by only
|
|
|
|
a few threads. With dynamic load balancing, if a thread finishes early we keep
|
|
|
|
feeding it more work.
|
|
|
|
|
|
|
|
When parmap is enabled, if an error occurs in Coccinelle, this error
|
2020-07-01 22:17:32 +03:00
|
|
|
value is propagated back, and the return value of the ``make coccicheck``
|
|
|
|
command captures this return value.
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Using Coccinelle with a single semantic patch
|
|
|
|
---------------------------------------------
|
2010-06-06 19:15:02 +04:00
|
|
|
|
|
|
|
The optional make variable COCCI can be used to check a single
|
|
|
|
semantic patch. In that case, the variable must be initialized with
|
|
|
|
the name of the semantic patch to apply.
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
For instance::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
|
|
|
make coccicheck COCCI=<my_SP.cocci> MODE=patch
|
2016-08-09 01:03:14 +03:00
|
|
|
|
|
|
|
or::
|
|
|
|
|
2010-06-06 19:15:02 +04:00
|
|
|
make coccicheck COCCI=<my_SP.cocci> MODE=report
|
|
|
|
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Controlling Which Files are Processed by Coccinelle
|
|
|
|
---------------------------------------------------
|
|
|
|
|
2011-11-06 05:59:44 +04:00
|
|
|
By default the entire kernel source tree is checked.
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
To apply Coccinelle to a specific directory, ``M=`` can be used.
|
|
|
|
For example, to check drivers/net/wireless/ one may write::
|
2010-10-13 02:49:07 +04:00
|
|
|
|
2011-11-06 05:59:44 +04:00
|
|
|
make coccicheck M=drivers/net/wireless/
|
2013-03-03 01:36:27 +04:00
|
|
|
|
2010-10-13 02:49:07 +04:00
|
|
|
To apply Coccinelle on a file basis, instead of a directory basis, the
|
2020-08-11 03:23:50 +03:00
|
|
|
C variable is used by the makefile to select which files to work with.
|
|
|
|
This variable can be used to run scripts for the entire kernel, a
|
|
|
|
specific directory, or for a single file.
|
2010-10-13 02:49:07 +04:00
|
|
|
|
2020-08-11 03:23:50 +03:00
|
|
|
For example, to check drivers/bluetooth/bfusb.c, the value 1 is
|
|
|
|
passed to the C variable to check files that make considers
|
|
|
|
need to be compiled.::
|
2010-10-13 02:49:07 +04:00
|
|
|
|
2020-08-11 03:23:50 +03:00
|
|
|
make C=1 CHECK=scripts/coccicheck drivers/bluetooth/bfusb.o
|
2010-10-13 02:49:07 +04:00
|
|
|
|
2020-08-11 03:23:50 +03:00
|
|
|
The value 2 is passed to the C variable to check files regardless of
|
|
|
|
whether they need to be compiled or not.::
|
|
|
|
|
|
|
|
make C=2 CHECK=scripts/coccicheck drivers/bluetooth/bfusb.o
|
2010-10-13 02:49:07 +04:00
|
|
|
|
2020-07-01 22:17:32 +03:00
|
|
|
In these modes, which work on a file basis, there is no information
|
2013-06-20 16:00:19 +04:00
|
|
|
about semantic patches displayed, and no commit message proposed.
|
|
|
|
|
2010-10-13 02:49:07 +04:00
|
|
|
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.
|
|
|
|
|
2013-06-20 16:00:19 +04:00
|
|
|
The "report" mode is the default. You can select another one with the
|
2010-10-13 02:49:07 +04:00
|
|
|
MODE variable explained above.
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Debugging Coccinelle SmPL patches
|
|
|
|
---------------------------------
|
2016-06-30 01:14:54 +03:00
|
|
|
|
|
|
|
Using coccicheck is best as it provides in the spatch command line
|
|
|
|
include options matching the options used when we compile the kernel.
|
2020-07-01 22:17:32 +03:00
|
|
|
You can learn what these options are by using V=1; you could then
|
2016-06-30 01:14:54 +03:00
|
|
|
manually run Coccinelle with debug options added.
|
|
|
|
|
|
|
|
Alternatively you can debug running Coccinelle against SmPL patches
|
2020-07-01 22:17:32 +03:00
|
|
|
by asking for stderr to be redirected to stderr. By default stderr
|
|
|
|
is redirected to /dev/null; if you'd like to capture stderr you
|
2016-08-09 01:03:14 +03:00
|
|
|
can specify the ``DEBUG_FILE="file.txt"`` option to coccicheck. For
|
|
|
|
instance::
|
2016-06-30 01:14:54 +03:00
|
|
|
|
|
|
|
rm -f cocci.err
|
|
|
|
make coccicheck COCCI=scripts/coccinelle/free/kfree.cocci MODE=report DEBUG_FILE=cocci.err
|
|
|
|
cat cocci.err
|
|
|
|
|
2020-07-01 22:17:32 +03:00
|
|
|
You can use SPFLAGS to add debugging flags; for instance you may want to
|
|
|
|
add both --profile --show-trying to SPFLAGS when debugging. For example
|
2016-08-09 01:03:14 +03:00
|
|
|
you may want to use::
|
2016-06-30 01:14:55 +03:00
|
|
|
|
|
|
|
rm -f err.log
|
|
|
|
export COCCI=scripts/coccinelle/misc/irqf_oneshot.cocci
|
|
|
|
make coccicheck DEBUG_FILE="err.log" MODE=report SPFLAGS="--profile --show-trying" M=./drivers/mfd/arizona-irq.c
|
|
|
|
|
|
|
|
err.log will now have the profiling information, while stdout will
|
|
|
|
provide some progress information as Coccinelle moves forward with
|
|
|
|
work.
|
|
|
|
|
2017-10-15 12:24:08 +03:00
|
|
|
DEBUG_FILE support is only supported when using coccinelle >= 1.0.2.
|
2016-06-30 01:14:54 +03:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
.cocciconfig support
|
|
|
|
--------------------
|
scripts: add Linux .cocciconfig for coccinelle
Coccinelle supports reading .cocciconfig, the order of precedence for
variables for .cocciconfig is as follows:
o Your current user's home directory is processed first
o Your directory from which spatch is called is processed next
o The directory provided with the --dir option is processed last, if used
Since coccicheck runs through make, it naturally runs from the kernel
proper dir, as such the second rule above would be implied for picking up a
.cocciconfig when using 'make coccicheck'.
'make coccicheck' also supports using M= targets.If you do not supply
any M= target, it is assumed you want to target the entire kernel.
The kernel coccicheck script has:
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="--dir $srctree $COCCIINCLUDE"
else
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
the spatch --dir argument is used, as such third rule applies when
whether M= is used or not, and when M= is used the target directory can
have its own .cocciconfig file. When M= is not passed as an argument to
coccicheck the target directory is the same as the directory from where
spatch was called.
If not using the kernel's coccicheck target, keep the above precedence order
logic of .cocciconfig reading. If using the kernel's coccicheck target,
override any of the kernel's .coccicheck's settings using SPFLAGS.
We help Coccinelle when used against Linux with a set of sensible defaults
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
git can be used for 'git grep' queries over coccigrep. A timeout of 200
seconds should suffice for now.
The options picked up by coccinelle when reading a .cocciconfig do not appear
as arguments to spatch processes running on your system, to confirm what
options will be used by Coccinelle run:
spatch --print-options-only
You can override with your own preferred index option by using SPFLAGS.
Coccinelle supports both glimpse and idutils. Glimpse had historically
provided the best performance, however recent benchmarks reveal idutils
is performing just as well. Due to some recent fixes however you however
will need at least coccinelle >= 1.0.6 if using idutils.
Coccinelle carries a script scripts/idutils_index.sh which creates the
idutils database with as follows:
mkid -i C --output .id-utils.index
If using just "--use-idutils" coccinelle expects your idutils database to be
on the top level of the kernel as a file named ".id-utils.index". If you do
not use this you can symlink your database file to it, or you can specify the
database file following the "--use-idutils" argument. Examples:
make SPFLAGS=--use-idutils coccicheck
This assumes you have $srctree/.id-utils.index, where $srctree is
the top level of the kernel.
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
Here you specify the full path of the idutils ID database. Using
.cocciconfig is possible, however given the order of precedence followed
by Coccinelle, and since the kernel now carries its own .cocciconfig,
you will need to use SPFLAGS to use idutils if desired.
v4:
o Recommend upgrade for using idutils with coccinelle due to some
recent fixes.
o Refer to using --print-options-only for testing what options are
picked up by .cocciconfig reading.
o Expand commit log considerably explaining *why* .cocconfig from
two precedence rules are used when using coccicheck, and how to
properly override these if needed.
o Expand Documentation/coccinelle.txt
v3: Expand commit log a bit more
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:56 +03:00
|
|
|
|
|
|
|
Coccinelle supports reading .cocciconfig for default Coccinelle options that
|
2020-07-01 22:17:32 +03:00
|
|
|
should be used every time spatch is spawned. The order of precedence for
|
scripts: add Linux .cocciconfig for coccinelle
Coccinelle supports reading .cocciconfig, the order of precedence for
variables for .cocciconfig is as follows:
o Your current user's home directory is processed first
o Your directory from which spatch is called is processed next
o The directory provided with the --dir option is processed last, if used
Since coccicheck runs through make, it naturally runs from the kernel
proper dir, as such the second rule above would be implied for picking up a
.cocciconfig when using 'make coccicheck'.
'make coccicheck' also supports using M= targets.If you do not supply
any M= target, it is assumed you want to target the entire kernel.
The kernel coccicheck script has:
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="--dir $srctree $COCCIINCLUDE"
else
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
the spatch --dir argument is used, as such third rule applies when
whether M= is used or not, and when M= is used the target directory can
have its own .cocciconfig file. When M= is not passed as an argument to
coccicheck the target directory is the same as the directory from where
spatch was called.
If not using the kernel's coccicheck target, keep the above precedence order
logic of .cocciconfig reading. If using the kernel's coccicheck target,
override any of the kernel's .coccicheck's settings using SPFLAGS.
We help Coccinelle when used against Linux with a set of sensible defaults
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
git can be used for 'git grep' queries over coccigrep. A timeout of 200
seconds should suffice for now.
The options picked up by coccinelle when reading a .cocciconfig do not appear
as arguments to spatch processes running on your system, to confirm what
options will be used by Coccinelle run:
spatch --print-options-only
You can override with your own preferred index option by using SPFLAGS.
Coccinelle supports both glimpse and idutils. Glimpse had historically
provided the best performance, however recent benchmarks reveal idutils
is performing just as well. Due to some recent fixes however you however
will need at least coccinelle >= 1.0.6 if using idutils.
Coccinelle carries a script scripts/idutils_index.sh which creates the
idutils database with as follows:
mkid -i C --output .id-utils.index
If using just "--use-idutils" coccinelle expects your idutils database to be
on the top level of the kernel as a file named ".id-utils.index". If you do
not use this you can symlink your database file to it, or you can specify the
database file following the "--use-idutils" argument. Examples:
make SPFLAGS=--use-idutils coccicheck
This assumes you have $srctree/.id-utils.index, where $srctree is
the top level of the kernel.
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
Here you specify the full path of the idutils ID database. Using
.cocciconfig is possible, however given the order of precedence followed
by Coccinelle, and since the kernel now carries its own .cocciconfig,
you will need to use SPFLAGS to use idutils if desired.
v4:
o Recommend upgrade for using idutils with coccinelle due to some
recent fixes.
o Refer to using --print-options-only for testing what options are
picked up by .cocciconfig reading.
o Expand commit log considerably explaining *why* .cocconfig from
two precedence rules are used when using coccicheck, and how to
properly override these if needed.
o Expand Documentation/coccinelle.txt
v3: Expand commit log a bit more
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:56 +03:00
|
|
|
variables for .cocciconfig is as follows:
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
- Your current user's home directory is processed first
|
|
|
|
- Your directory from which spatch is called is processed next
|
|
|
|
- The directory provided with the --dir option is processed last, if used
|
scripts: add Linux .cocciconfig for coccinelle
Coccinelle supports reading .cocciconfig, the order of precedence for
variables for .cocciconfig is as follows:
o Your current user's home directory is processed first
o Your directory from which spatch is called is processed next
o The directory provided with the --dir option is processed last, if used
Since coccicheck runs through make, it naturally runs from the kernel
proper dir, as such the second rule above would be implied for picking up a
.cocciconfig when using 'make coccicheck'.
'make coccicheck' also supports using M= targets.If you do not supply
any M= target, it is assumed you want to target the entire kernel.
The kernel coccicheck script has:
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="--dir $srctree $COCCIINCLUDE"
else
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
the spatch --dir argument is used, as such third rule applies when
whether M= is used or not, and when M= is used the target directory can
have its own .cocciconfig file. When M= is not passed as an argument to
coccicheck the target directory is the same as the directory from where
spatch was called.
If not using the kernel's coccicheck target, keep the above precedence order
logic of .cocciconfig reading. If using the kernel's coccicheck target,
override any of the kernel's .coccicheck's settings using SPFLAGS.
We help Coccinelle when used against Linux with a set of sensible defaults
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
git can be used for 'git grep' queries over coccigrep. A timeout of 200
seconds should suffice for now.
The options picked up by coccinelle when reading a .cocciconfig do not appear
as arguments to spatch processes running on your system, to confirm what
options will be used by Coccinelle run:
spatch --print-options-only
You can override with your own preferred index option by using SPFLAGS.
Coccinelle supports both glimpse and idutils. Glimpse had historically
provided the best performance, however recent benchmarks reveal idutils
is performing just as well. Due to some recent fixes however you however
will need at least coccinelle >= 1.0.6 if using idutils.
Coccinelle carries a script scripts/idutils_index.sh which creates the
idutils database with as follows:
mkid -i C --output .id-utils.index
If using just "--use-idutils" coccinelle expects your idutils database to be
on the top level of the kernel as a file named ".id-utils.index". If you do
not use this you can symlink your database file to it, or you can specify the
database file following the "--use-idutils" argument. Examples:
make SPFLAGS=--use-idutils coccicheck
This assumes you have $srctree/.id-utils.index, where $srctree is
the top level of the kernel.
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
Here you specify the full path of the idutils ID database. Using
.cocciconfig is possible, however given the order of precedence followed
by Coccinelle, and since the kernel now carries its own .cocciconfig,
you will need to use SPFLAGS to use idutils if desired.
v4:
o Recommend upgrade for using idutils with coccinelle due to some
recent fixes.
o Refer to using --print-options-only for testing what options are
picked up by .cocciconfig reading.
o Expand commit log considerably explaining *why* .cocconfig from
two precedence rules are used when using coccicheck, and how to
properly override these if needed.
o Expand Documentation/coccinelle.txt
v3: Expand commit log a bit more
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:56 +03:00
|
|
|
|
|
|
|
Since coccicheck runs through make, it naturally runs from the kernel
|
2020-07-01 22:17:32 +03:00
|
|
|
proper dir; as such the second rule above would be implied for picking up a
|
2016-08-09 01:03:14 +03:00
|
|
|
.cocciconfig when using ``make coccicheck``.
|
scripts: add Linux .cocciconfig for coccinelle
Coccinelle supports reading .cocciconfig, the order of precedence for
variables for .cocciconfig is as follows:
o Your current user's home directory is processed first
o Your directory from which spatch is called is processed next
o The directory provided with the --dir option is processed last, if used
Since coccicheck runs through make, it naturally runs from the kernel
proper dir, as such the second rule above would be implied for picking up a
.cocciconfig when using 'make coccicheck'.
'make coccicheck' also supports using M= targets.If you do not supply
any M= target, it is assumed you want to target the entire kernel.
The kernel coccicheck script has:
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="--dir $srctree $COCCIINCLUDE"
else
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
the spatch --dir argument is used, as such third rule applies when
whether M= is used or not, and when M= is used the target directory can
have its own .cocciconfig file. When M= is not passed as an argument to
coccicheck the target directory is the same as the directory from where
spatch was called.
If not using the kernel's coccicheck target, keep the above precedence order
logic of .cocciconfig reading. If using the kernel's coccicheck target,
override any of the kernel's .coccicheck's settings using SPFLAGS.
We help Coccinelle when used against Linux with a set of sensible defaults
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
git can be used for 'git grep' queries over coccigrep. A timeout of 200
seconds should suffice for now.
The options picked up by coccinelle when reading a .cocciconfig do not appear
as arguments to spatch processes running on your system, to confirm what
options will be used by Coccinelle run:
spatch --print-options-only
You can override with your own preferred index option by using SPFLAGS.
Coccinelle supports both glimpse and idutils. Glimpse had historically
provided the best performance, however recent benchmarks reveal idutils
is performing just as well. Due to some recent fixes however you however
will need at least coccinelle >= 1.0.6 if using idutils.
Coccinelle carries a script scripts/idutils_index.sh which creates the
idutils database with as follows:
mkid -i C --output .id-utils.index
If using just "--use-idutils" coccinelle expects your idutils database to be
on the top level of the kernel as a file named ".id-utils.index". If you do
not use this you can symlink your database file to it, or you can specify the
database file following the "--use-idutils" argument. Examples:
make SPFLAGS=--use-idutils coccicheck
This assumes you have $srctree/.id-utils.index, where $srctree is
the top level of the kernel.
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
Here you specify the full path of the idutils ID database. Using
.cocciconfig is possible, however given the order of precedence followed
by Coccinelle, and since the kernel now carries its own .cocciconfig,
you will need to use SPFLAGS to use idutils if desired.
v4:
o Recommend upgrade for using idutils with coccinelle due to some
recent fixes.
o Refer to using --print-options-only for testing what options are
picked up by .cocciconfig reading.
o Expand commit log considerably explaining *why* .cocconfig from
two precedence rules are used when using coccicheck, and how to
properly override these if needed.
o Expand Documentation/coccinelle.txt
v3: Expand commit log a bit more
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:56 +03:00
|
|
|
|
2018-08-13 13:46:38 +03:00
|
|
|
``make coccicheck`` also supports using M= targets. If you do not supply
|
scripts: add Linux .cocciconfig for coccinelle
Coccinelle supports reading .cocciconfig, the order of precedence for
variables for .cocciconfig is as follows:
o Your current user's home directory is processed first
o Your directory from which spatch is called is processed next
o The directory provided with the --dir option is processed last, if used
Since coccicheck runs through make, it naturally runs from the kernel
proper dir, as such the second rule above would be implied for picking up a
.cocciconfig when using 'make coccicheck'.
'make coccicheck' also supports using M= targets.If you do not supply
any M= target, it is assumed you want to target the entire kernel.
The kernel coccicheck script has:
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="--dir $srctree $COCCIINCLUDE"
else
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
the spatch --dir argument is used, as such third rule applies when
whether M= is used or not, and when M= is used the target directory can
have its own .cocciconfig file. When M= is not passed as an argument to
coccicheck the target directory is the same as the directory from where
spatch was called.
If not using the kernel's coccicheck target, keep the above precedence order
logic of .cocciconfig reading. If using the kernel's coccicheck target,
override any of the kernel's .coccicheck's settings using SPFLAGS.
We help Coccinelle when used against Linux with a set of sensible defaults
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
git can be used for 'git grep' queries over coccigrep. A timeout of 200
seconds should suffice for now.
The options picked up by coccinelle when reading a .cocciconfig do not appear
as arguments to spatch processes running on your system, to confirm what
options will be used by Coccinelle run:
spatch --print-options-only
You can override with your own preferred index option by using SPFLAGS.
Coccinelle supports both glimpse and idutils. Glimpse had historically
provided the best performance, however recent benchmarks reveal idutils
is performing just as well. Due to some recent fixes however you however
will need at least coccinelle >= 1.0.6 if using idutils.
Coccinelle carries a script scripts/idutils_index.sh which creates the
idutils database with as follows:
mkid -i C --output .id-utils.index
If using just "--use-idutils" coccinelle expects your idutils database to be
on the top level of the kernel as a file named ".id-utils.index". If you do
not use this you can symlink your database file to it, or you can specify the
database file following the "--use-idutils" argument. Examples:
make SPFLAGS=--use-idutils coccicheck
This assumes you have $srctree/.id-utils.index, where $srctree is
the top level of the kernel.
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
Here you specify the full path of the idutils ID database. Using
.cocciconfig is possible, however given the order of precedence followed
by Coccinelle, and since the kernel now carries its own .cocciconfig,
you will need to use SPFLAGS to use idutils if desired.
v4:
o Recommend upgrade for using idutils with coccinelle due to some
recent fixes.
o Refer to using --print-options-only for testing what options are
picked up by .cocciconfig reading.
o Expand commit log considerably explaining *why* .cocconfig from
two precedence rules are used when using coccicheck, and how to
properly override these if needed.
o Expand Documentation/coccinelle.txt
v3: Expand commit log a bit more
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:56 +03:00
|
|
|
any M= target, it is assumed you want to target the entire kernel.
|
2016-08-09 01:03:14 +03:00
|
|
|
The kernel coccicheck script has::
|
scripts: add Linux .cocciconfig for coccinelle
Coccinelle supports reading .cocciconfig, the order of precedence for
variables for .cocciconfig is as follows:
o Your current user's home directory is processed first
o Your directory from which spatch is called is processed next
o The directory provided with the --dir option is processed last, if used
Since coccicheck runs through make, it naturally runs from the kernel
proper dir, as such the second rule above would be implied for picking up a
.cocciconfig when using 'make coccicheck'.
'make coccicheck' also supports using M= targets.If you do not supply
any M= target, it is assumed you want to target the entire kernel.
The kernel coccicheck script has:
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="--dir $srctree $COCCIINCLUDE"
else
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
the spatch --dir argument is used, as such third rule applies when
whether M= is used or not, and when M= is used the target directory can
have its own .cocciconfig file. When M= is not passed as an argument to
coccicheck the target directory is the same as the directory from where
spatch was called.
If not using the kernel's coccicheck target, keep the above precedence order
logic of .cocciconfig reading. If using the kernel's coccicheck target,
override any of the kernel's .coccicheck's settings using SPFLAGS.
We help Coccinelle when used against Linux with a set of sensible defaults
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
git can be used for 'git grep' queries over coccigrep. A timeout of 200
seconds should suffice for now.
The options picked up by coccinelle when reading a .cocciconfig do not appear
as arguments to spatch processes running on your system, to confirm what
options will be used by Coccinelle run:
spatch --print-options-only
You can override with your own preferred index option by using SPFLAGS.
Coccinelle supports both glimpse and idutils. Glimpse had historically
provided the best performance, however recent benchmarks reveal idutils
is performing just as well. Due to some recent fixes however you however
will need at least coccinelle >= 1.0.6 if using idutils.
Coccinelle carries a script scripts/idutils_index.sh which creates the
idutils database with as follows:
mkid -i C --output .id-utils.index
If using just "--use-idutils" coccinelle expects your idutils database to be
on the top level of the kernel as a file named ".id-utils.index". If you do
not use this you can symlink your database file to it, or you can specify the
database file following the "--use-idutils" argument. Examples:
make SPFLAGS=--use-idutils coccicheck
This assumes you have $srctree/.id-utils.index, where $srctree is
the top level of the kernel.
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
Here you specify the full path of the idutils ID database. Using
.cocciconfig is possible, however given the order of precedence followed
by Coccinelle, and since the kernel now carries its own .cocciconfig,
you will need to use SPFLAGS to use idutils if desired.
v4:
o Recommend upgrade for using idutils with coccinelle due to some
recent fixes.
o Refer to using --print-options-only for testing what options are
picked up by .cocciconfig reading.
o Expand commit log considerably explaining *why* .cocconfig from
two precedence rules are used when using coccicheck, and how to
properly override these if needed.
o Expand Documentation/coccinelle.txt
v3: Expand commit log a bit more
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:56 +03:00
|
|
|
|
|
|
|
if [ "$KBUILD_EXTMOD" = "" ] ; then
|
|
|
|
OPTIONS="--dir $srctree $COCCIINCLUDE"
|
|
|
|
else
|
|
|
|
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
|
|
|
|
the spatch --dir argument is used, as such third rule applies when whether M=
|
|
|
|
is used or not, and when M= is used the target directory can have its own
|
|
|
|
.cocciconfig file. When M= is not passed as an argument to coccicheck the
|
|
|
|
target directory is the same as the directory from where spatch was called.
|
|
|
|
|
|
|
|
If not using the kernel's coccicheck target, keep the above precedence
|
|
|
|
order logic of .cocciconfig reading. If using the kernel's coccicheck target,
|
|
|
|
override any of the kernel's .coccicheck's settings using SPFLAGS.
|
|
|
|
|
2020-07-01 22:17:32 +03:00
|
|
|
We help Coccinelle when used against Linux with a set of sensible default
|
scripts: add Linux .cocciconfig for coccinelle
Coccinelle supports reading .cocciconfig, the order of precedence for
variables for .cocciconfig is as follows:
o Your current user's home directory is processed first
o Your directory from which spatch is called is processed next
o The directory provided with the --dir option is processed last, if used
Since coccicheck runs through make, it naturally runs from the kernel
proper dir, as such the second rule above would be implied for picking up a
.cocciconfig when using 'make coccicheck'.
'make coccicheck' also supports using M= targets.If you do not supply
any M= target, it is assumed you want to target the entire kernel.
The kernel coccicheck script has:
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="--dir $srctree $COCCIINCLUDE"
else
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
the spatch --dir argument is used, as such third rule applies when
whether M= is used or not, and when M= is used the target directory can
have its own .cocciconfig file. When M= is not passed as an argument to
coccicheck the target directory is the same as the directory from where
spatch was called.
If not using the kernel's coccicheck target, keep the above precedence order
logic of .cocciconfig reading. If using the kernel's coccicheck target,
override any of the kernel's .coccicheck's settings using SPFLAGS.
We help Coccinelle when used against Linux with a set of sensible defaults
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
git can be used for 'git grep' queries over coccigrep. A timeout of 200
seconds should suffice for now.
The options picked up by coccinelle when reading a .cocciconfig do not appear
as arguments to spatch processes running on your system, to confirm what
options will be used by Coccinelle run:
spatch --print-options-only
You can override with your own preferred index option by using SPFLAGS.
Coccinelle supports both glimpse and idutils. Glimpse had historically
provided the best performance, however recent benchmarks reveal idutils
is performing just as well. Due to some recent fixes however you however
will need at least coccinelle >= 1.0.6 if using idutils.
Coccinelle carries a script scripts/idutils_index.sh which creates the
idutils database with as follows:
mkid -i C --output .id-utils.index
If using just "--use-idutils" coccinelle expects your idutils database to be
on the top level of the kernel as a file named ".id-utils.index". If you do
not use this you can symlink your database file to it, or you can specify the
database file following the "--use-idutils" argument. Examples:
make SPFLAGS=--use-idutils coccicheck
This assumes you have $srctree/.id-utils.index, where $srctree is
the top level of the kernel.
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
Here you specify the full path of the idutils ID database. Using
.cocciconfig is possible, however given the order of precedence followed
by Coccinelle, and since the kernel now carries its own .cocciconfig,
you will need to use SPFLAGS to use idutils if desired.
v4:
o Recommend upgrade for using idutils with coccinelle due to some
recent fixes.
o Refer to using --print-options-only for testing what options are
picked up by .cocciconfig reading.
o Expand commit log considerably explaining *why* .cocconfig from
two precedence rules are used when using coccicheck, and how to
properly override these if needed.
o Expand Documentation/coccinelle.txt
v3: Expand commit log a bit more
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:56 +03:00
|
|
|
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
|
2020-07-01 22:17:32 +03:00
|
|
|
that git can be used for ``git grep`` queries over coccigrep. A timeout of 200
|
scripts: add Linux .cocciconfig for coccinelle
Coccinelle supports reading .cocciconfig, the order of precedence for
variables for .cocciconfig is as follows:
o Your current user's home directory is processed first
o Your directory from which spatch is called is processed next
o The directory provided with the --dir option is processed last, if used
Since coccicheck runs through make, it naturally runs from the kernel
proper dir, as such the second rule above would be implied for picking up a
.cocciconfig when using 'make coccicheck'.
'make coccicheck' also supports using M= targets.If you do not supply
any M= target, it is assumed you want to target the entire kernel.
The kernel coccicheck script has:
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="--dir $srctree $COCCIINCLUDE"
else
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
the spatch --dir argument is used, as such third rule applies when
whether M= is used or not, and when M= is used the target directory can
have its own .cocciconfig file. When M= is not passed as an argument to
coccicheck the target directory is the same as the directory from where
spatch was called.
If not using the kernel's coccicheck target, keep the above precedence order
logic of .cocciconfig reading. If using the kernel's coccicheck target,
override any of the kernel's .coccicheck's settings using SPFLAGS.
We help Coccinelle when used against Linux with a set of sensible defaults
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
git can be used for 'git grep' queries over coccigrep. A timeout of 200
seconds should suffice for now.
The options picked up by coccinelle when reading a .cocciconfig do not appear
as arguments to spatch processes running on your system, to confirm what
options will be used by Coccinelle run:
spatch --print-options-only
You can override with your own preferred index option by using SPFLAGS.
Coccinelle supports both glimpse and idutils. Glimpse had historically
provided the best performance, however recent benchmarks reveal idutils
is performing just as well. Due to some recent fixes however you however
will need at least coccinelle >= 1.0.6 if using idutils.
Coccinelle carries a script scripts/idutils_index.sh which creates the
idutils database with as follows:
mkid -i C --output .id-utils.index
If using just "--use-idutils" coccinelle expects your idutils database to be
on the top level of the kernel as a file named ".id-utils.index". If you do
not use this you can symlink your database file to it, or you can specify the
database file following the "--use-idutils" argument. Examples:
make SPFLAGS=--use-idutils coccicheck
This assumes you have $srctree/.id-utils.index, where $srctree is
the top level of the kernel.
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
Here you specify the full path of the idutils ID database. Using
.cocciconfig is possible, however given the order of precedence followed
by Coccinelle, and since the kernel now carries its own .cocciconfig,
you will need to use SPFLAGS to use idutils if desired.
v4:
o Recommend upgrade for using idutils with coccinelle due to some
recent fixes.
o Refer to using --print-options-only for testing what options are
picked up by .cocciconfig reading.
o Expand commit log considerably explaining *why* .cocconfig from
two precedence rules are used when using coccicheck, and how to
properly override these if needed.
o Expand Documentation/coccinelle.txt
v3: Expand commit log a bit more
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:56 +03:00
|
|
|
seconds should suffice for now.
|
|
|
|
|
|
|
|
The options picked up by coccinelle when reading a .cocciconfig do not appear
|
2020-07-01 22:17:32 +03:00
|
|
|
as arguments to spatch processes running on your system. To confirm what
|
2016-08-09 01:03:14 +03:00
|
|
|
options will be used by Coccinelle run::
|
scripts: add Linux .cocciconfig for coccinelle
Coccinelle supports reading .cocciconfig, the order of precedence for
variables for .cocciconfig is as follows:
o Your current user's home directory is processed first
o Your directory from which spatch is called is processed next
o The directory provided with the --dir option is processed last, if used
Since coccicheck runs through make, it naturally runs from the kernel
proper dir, as such the second rule above would be implied for picking up a
.cocciconfig when using 'make coccicheck'.
'make coccicheck' also supports using M= targets.If you do not supply
any M= target, it is assumed you want to target the entire kernel.
The kernel coccicheck script has:
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="--dir $srctree $COCCIINCLUDE"
else
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
the spatch --dir argument is used, as such third rule applies when
whether M= is used or not, and when M= is used the target directory can
have its own .cocciconfig file. When M= is not passed as an argument to
coccicheck the target directory is the same as the directory from where
spatch was called.
If not using the kernel's coccicheck target, keep the above precedence order
logic of .cocciconfig reading. If using the kernel's coccicheck target,
override any of the kernel's .coccicheck's settings using SPFLAGS.
We help Coccinelle when used against Linux with a set of sensible defaults
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
git can be used for 'git grep' queries over coccigrep. A timeout of 200
seconds should suffice for now.
The options picked up by coccinelle when reading a .cocciconfig do not appear
as arguments to spatch processes running on your system, to confirm what
options will be used by Coccinelle run:
spatch --print-options-only
You can override with your own preferred index option by using SPFLAGS.
Coccinelle supports both glimpse and idutils. Glimpse had historically
provided the best performance, however recent benchmarks reveal idutils
is performing just as well. Due to some recent fixes however you however
will need at least coccinelle >= 1.0.6 if using idutils.
Coccinelle carries a script scripts/idutils_index.sh which creates the
idutils database with as follows:
mkid -i C --output .id-utils.index
If using just "--use-idutils" coccinelle expects your idutils database to be
on the top level of the kernel as a file named ".id-utils.index". If you do
not use this you can symlink your database file to it, or you can specify the
database file following the "--use-idutils" argument. Examples:
make SPFLAGS=--use-idutils coccicheck
This assumes you have $srctree/.id-utils.index, where $srctree is
the top level of the kernel.
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
Here you specify the full path of the idutils ID database. Using
.cocciconfig is possible, however given the order of precedence followed
by Coccinelle, and since the kernel now carries its own .cocciconfig,
you will need to use SPFLAGS to use idutils if desired.
v4:
o Recommend upgrade for using idutils with coccinelle due to some
recent fixes.
o Refer to using --print-options-only for testing what options are
picked up by .cocciconfig reading.
o Expand commit log considerably explaining *why* .cocconfig from
two precedence rules are used when using coccicheck, and how to
properly override these if needed.
o Expand Documentation/coccinelle.txt
v3: Expand commit log a bit more
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:56 +03:00
|
|
|
|
|
|
|
spatch --print-options-only
|
|
|
|
|
|
|
|
You can override with your own preferred index option by using SPFLAGS. Take
|
|
|
|
note that when there are conflicting options Coccinelle takes precedence for
|
|
|
|
the last options passed. Using .cocciconfig is possible to use idutils, however
|
|
|
|
given the order of precedence followed by Coccinelle, since the kernel now
|
|
|
|
carries its own .cocciconfig, you will need to use SPFLAGS to use idutils if
|
|
|
|
desired. See below section "Additional flags" for more details on how to use
|
|
|
|
idutils.
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Additional flags
|
|
|
|
----------------
|
2013-03-03 01:36:27 +04:00
|
|
|
|
|
|
|
Additional flags can be passed to spatch through the SPFLAGS
|
2016-06-30 01:14:52 +03:00
|
|
|
variable. This works as Coccinelle respects the last flags
|
2016-08-09 01:03:14 +03:00
|
|
|
given to it when options are in conflict. ::
|
2013-03-03 01:36:27 +04:00
|
|
|
|
2013-06-20 16:00:19 +04:00
|
|
|
make SPFLAGS=--use-glimpse coccicheck
|
scripts: add Linux .cocciconfig for coccinelle
Coccinelle supports reading .cocciconfig, the order of precedence for
variables for .cocciconfig is as follows:
o Your current user's home directory is processed first
o Your directory from which spatch is called is processed next
o The directory provided with the --dir option is processed last, if used
Since coccicheck runs through make, it naturally runs from the kernel
proper dir, as such the second rule above would be implied for picking up a
.cocciconfig when using 'make coccicheck'.
'make coccicheck' also supports using M= targets.If you do not supply
any M= target, it is assumed you want to target the entire kernel.
The kernel coccicheck script has:
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="--dir $srctree $COCCIINCLUDE"
else
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
the spatch --dir argument is used, as such third rule applies when
whether M= is used or not, and when M= is used the target directory can
have its own .cocciconfig file. When M= is not passed as an argument to
coccicheck the target directory is the same as the directory from where
spatch was called.
If not using the kernel's coccicheck target, keep the above precedence order
logic of .cocciconfig reading. If using the kernel's coccicheck target,
override any of the kernel's .coccicheck's settings using SPFLAGS.
We help Coccinelle when used against Linux with a set of sensible defaults
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
git can be used for 'git grep' queries over coccigrep. A timeout of 200
seconds should suffice for now.
The options picked up by coccinelle when reading a .cocciconfig do not appear
as arguments to spatch processes running on your system, to confirm what
options will be used by Coccinelle run:
spatch --print-options-only
You can override with your own preferred index option by using SPFLAGS.
Coccinelle supports both glimpse and idutils. Glimpse had historically
provided the best performance, however recent benchmarks reveal idutils
is performing just as well. Due to some recent fixes however you however
will need at least coccinelle >= 1.0.6 if using idutils.
Coccinelle carries a script scripts/idutils_index.sh which creates the
idutils database with as follows:
mkid -i C --output .id-utils.index
If using just "--use-idutils" coccinelle expects your idutils database to be
on the top level of the kernel as a file named ".id-utils.index". If you do
not use this you can symlink your database file to it, or you can specify the
database file following the "--use-idutils" argument. Examples:
make SPFLAGS=--use-idutils coccicheck
This assumes you have $srctree/.id-utils.index, where $srctree is
the top level of the kernel.
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
Here you specify the full path of the idutils ID database. Using
.cocciconfig is possible, however given the order of precedence followed
by Coccinelle, and since the kernel now carries its own .cocciconfig,
you will need to use SPFLAGS to use idutils if desired.
v4:
o Recommend upgrade for using idutils with coccinelle due to some
recent fixes.
o Refer to using --print-options-only for testing what options are
picked up by .cocciconfig reading.
o Expand commit log considerably explaining *why* .cocconfig from
two precedence rules are used when using coccicheck, and how to
properly override these if needed.
o Expand Documentation/coccinelle.txt
v3: Expand commit log a bit more
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:56 +03:00
|
|
|
|
|
|
|
Coccinelle supports idutils as well but requires coccinelle >= 1.0.6.
|
|
|
|
When no ID file is specified coccinelle assumes your ID database file
|
2020-07-01 22:17:32 +03:00
|
|
|
is in the file .id-utils.index on the top level of the kernel. Coccinelle
|
2016-08-09 01:03:14 +03:00
|
|
|
carries a script scripts/idutils_index.sh which creates the database with::
|
scripts: add Linux .cocciconfig for coccinelle
Coccinelle supports reading .cocciconfig, the order of precedence for
variables for .cocciconfig is as follows:
o Your current user's home directory is processed first
o Your directory from which spatch is called is processed next
o The directory provided with the --dir option is processed last, if used
Since coccicheck runs through make, it naturally runs from the kernel
proper dir, as such the second rule above would be implied for picking up a
.cocciconfig when using 'make coccicheck'.
'make coccicheck' also supports using M= targets.If you do not supply
any M= target, it is assumed you want to target the entire kernel.
The kernel coccicheck script has:
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="--dir $srctree $COCCIINCLUDE"
else
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
the spatch --dir argument is used, as such third rule applies when
whether M= is used or not, and when M= is used the target directory can
have its own .cocciconfig file. When M= is not passed as an argument to
coccicheck the target directory is the same as the directory from where
spatch was called.
If not using the kernel's coccicheck target, keep the above precedence order
logic of .cocciconfig reading. If using the kernel's coccicheck target,
override any of the kernel's .coccicheck's settings using SPFLAGS.
We help Coccinelle when used against Linux with a set of sensible defaults
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
git can be used for 'git grep' queries over coccigrep. A timeout of 200
seconds should suffice for now.
The options picked up by coccinelle when reading a .cocciconfig do not appear
as arguments to spatch processes running on your system, to confirm what
options will be used by Coccinelle run:
spatch --print-options-only
You can override with your own preferred index option by using SPFLAGS.
Coccinelle supports both glimpse and idutils. Glimpse had historically
provided the best performance, however recent benchmarks reveal idutils
is performing just as well. Due to some recent fixes however you however
will need at least coccinelle >= 1.0.6 if using idutils.
Coccinelle carries a script scripts/idutils_index.sh which creates the
idutils database with as follows:
mkid -i C --output .id-utils.index
If using just "--use-idutils" coccinelle expects your idutils database to be
on the top level of the kernel as a file named ".id-utils.index". If you do
not use this you can symlink your database file to it, or you can specify the
database file following the "--use-idutils" argument. Examples:
make SPFLAGS=--use-idutils coccicheck
This assumes you have $srctree/.id-utils.index, where $srctree is
the top level of the kernel.
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
Here you specify the full path of the idutils ID database. Using
.cocciconfig is possible, however given the order of precedence followed
by Coccinelle, and since the kernel now carries its own .cocciconfig,
you will need to use SPFLAGS to use idutils if desired.
v4:
o Recommend upgrade for using idutils with coccinelle due to some
recent fixes.
o Refer to using --print-options-only for testing what options are
picked up by .cocciconfig reading.
o Expand commit log considerably explaining *why* .cocconfig from
two precedence rules are used when using coccicheck, and how to
properly override these if needed.
o Expand Documentation/coccinelle.txt
v3: Expand commit log a bit more
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:56 +03:00
|
|
|
|
|
|
|
mkid -i C --output .id-utils.index
|
|
|
|
|
|
|
|
If you have another database filename you can also just symlink with this
|
2016-08-09 01:03:14 +03:00
|
|
|
name. ::
|
scripts: add Linux .cocciconfig for coccinelle
Coccinelle supports reading .cocciconfig, the order of precedence for
variables for .cocciconfig is as follows:
o Your current user's home directory is processed first
o Your directory from which spatch is called is processed next
o The directory provided with the --dir option is processed last, if used
Since coccicheck runs through make, it naturally runs from the kernel
proper dir, as such the second rule above would be implied for picking up a
.cocciconfig when using 'make coccicheck'.
'make coccicheck' also supports using M= targets.If you do not supply
any M= target, it is assumed you want to target the entire kernel.
The kernel coccicheck script has:
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="--dir $srctree $COCCIINCLUDE"
else
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
the spatch --dir argument is used, as such third rule applies when
whether M= is used or not, and when M= is used the target directory can
have its own .cocciconfig file. When M= is not passed as an argument to
coccicheck the target directory is the same as the directory from where
spatch was called.
If not using the kernel's coccicheck target, keep the above precedence order
logic of .cocciconfig reading. If using the kernel's coccicheck target,
override any of the kernel's .coccicheck's settings using SPFLAGS.
We help Coccinelle when used against Linux with a set of sensible defaults
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
git can be used for 'git grep' queries over coccigrep. A timeout of 200
seconds should suffice for now.
The options picked up by coccinelle when reading a .cocciconfig do not appear
as arguments to spatch processes running on your system, to confirm what
options will be used by Coccinelle run:
spatch --print-options-only
You can override with your own preferred index option by using SPFLAGS.
Coccinelle supports both glimpse and idutils. Glimpse had historically
provided the best performance, however recent benchmarks reveal idutils
is performing just as well. Due to some recent fixes however you however
will need at least coccinelle >= 1.0.6 if using idutils.
Coccinelle carries a script scripts/idutils_index.sh which creates the
idutils database with as follows:
mkid -i C --output .id-utils.index
If using just "--use-idutils" coccinelle expects your idutils database to be
on the top level of the kernel as a file named ".id-utils.index". If you do
not use this you can symlink your database file to it, or you can specify the
database file following the "--use-idutils" argument. Examples:
make SPFLAGS=--use-idutils coccicheck
This assumes you have $srctree/.id-utils.index, where $srctree is
the top level of the kernel.
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
Here you specify the full path of the idutils ID database. Using
.cocciconfig is possible, however given the order of precedence followed
by Coccinelle, and since the kernel now carries its own .cocciconfig,
you will need to use SPFLAGS to use idutils if desired.
v4:
o Recommend upgrade for using idutils with coccinelle due to some
recent fixes.
o Refer to using --print-options-only for testing what options are
picked up by .cocciconfig reading.
o Expand commit log considerably explaining *why* .cocconfig from
two precedence rules are used when using coccicheck, and how to
properly override these if needed.
o Expand Documentation/coccinelle.txt
v3: Expand commit log a bit more
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:56 +03:00
|
|
|
|
2013-06-20 16:00:19 +04:00
|
|
|
make SPFLAGS=--use-idutils coccicheck
|
2013-03-03 01:36:27 +04:00
|
|
|
|
scripts: add Linux .cocciconfig for coccinelle
Coccinelle supports reading .cocciconfig, the order of precedence for
variables for .cocciconfig is as follows:
o Your current user's home directory is processed first
o Your directory from which spatch is called is processed next
o The directory provided with the --dir option is processed last, if used
Since coccicheck runs through make, it naturally runs from the kernel
proper dir, as such the second rule above would be implied for picking up a
.cocciconfig when using 'make coccicheck'.
'make coccicheck' also supports using M= targets.If you do not supply
any M= target, it is assumed you want to target the entire kernel.
The kernel coccicheck script has:
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="--dir $srctree $COCCIINCLUDE"
else
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
the spatch --dir argument is used, as such third rule applies when
whether M= is used or not, and when M= is used the target directory can
have its own .cocciconfig file. When M= is not passed as an argument to
coccicheck the target directory is the same as the directory from where
spatch was called.
If not using the kernel's coccicheck target, keep the above precedence order
logic of .cocciconfig reading. If using the kernel's coccicheck target,
override any of the kernel's .coccicheck's settings using SPFLAGS.
We help Coccinelle when used against Linux with a set of sensible defaults
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
git can be used for 'git grep' queries over coccigrep. A timeout of 200
seconds should suffice for now.
The options picked up by coccinelle when reading a .cocciconfig do not appear
as arguments to spatch processes running on your system, to confirm what
options will be used by Coccinelle run:
spatch --print-options-only
You can override with your own preferred index option by using SPFLAGS.
Coccinelle supports both glimpse and idutils. Glimpse had historically
provided the best performance, however recent benchmarks reveal idutils
is performing just as well. Due to some recent fixes however you however
will need at least coccinelle >= 1.0.6 if using idutils.
Coccinelle carries a script scripts/idutils_index.sh which creates the
idutils database with as follows:
mkid -i C --output .id-utils.index
If using just "--use-idutils" coccinelle expects your idutils database to be
on the top level of the kernel as a file named ".id-utils.index". If you do
not use this you can symlink your database file to it, or you can specify the
database file following the "--use-idutils" argument. Examples:
make SPFLAGS=--use-idutils coccicheck
This assumes you have $srctree/.id-utils.index, where $srctree is
the top level of the kernel.
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
Here you specify the full path of the idutils ID database. Using
.cocciconfig is possible, however given the order of precedence followed
by Coccinelle, and since the kernel now carries its own .cocciconfig,
you will need to use SPFLAGS to use idutils if desired.
v4:
o Recommend upgrade for using idutils with coccinelle due to some
recent fixes.
o Refer to using --print-options-only for testing what options are
picked up by .cocciconfig reading.
o Expand commit log considerably explaining *why* .cocconfig from
two precedence rules are used when using coccicheck, and how to
properly override these if needed.
o Expand Documentation/coccinelle.txt
v3: Expand commit log a bit more
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:56 +03:00
|
|
|
Alternatively you can specify the database filename explicitly, for
|
2016-08-09 01:03:14 +03:00
|
|
|
instance::
|
scripts: add Linux .cocciconfig for coccinelle
Coccinelle supports reading .cocciconfig, the order of precedence for
variables for .cocciconfig is as follows:
o Your current user's home directory is processed first
o Your directory from which spatch is called is processed next
o The directory provided with the --dir option is processed last, if used
Since coccicheck runs through make, it naturally runs from the kernel
proper dir, as such the second rule above would be implied for picking up a
.cocciconfig when using 'make coccicheck'.
'make coccicheck' also supports using M= targets.If you do not supply
any M= target, it is assumed you want to target the entire kernel.
The kernel coccicheck script has:
if [ "$KBUILD_EXTMOD" = "" ] ; then
OPTIONS="--dir $srctree $COCCIINCLUDE"
else
OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
fi
KBUILD_EXTMOD is set when an explicit target with M= is used. For both cases
the spatch --dir argument is used, as such third rule applies when
whether M= is used or not, and when M= is used the target directory can
have its own .cocciconfig file. When M= is not passed as an argument to
coccicheck the target directory is the same as the directory from where
spatch was called.
If not using the kernel's coccicheck target, keep the above precedence order
logic of .cocciconfig reading. If using the kernel's coccicheck target,
override any of the kernel's .coccicheck's settings using SPFLAGS.
We help Coccinelle when used against Linux with a set of sensible defaults
options for Linux with our own Linux .cocciconfig. This hints to coccinelle
git can be used for 'git grep' queries over coccigrep. A timeout of 200
seconds should suffice for now.
The options picked up by coccinelle when reading a .cocciconfig do not appear
as arguments to spatch processes running on your system, to confirm what
options will be used by Coccinelle run:
spatch --print-options-only
You can override with your own preferred index option by using SPFLAGS.
Coccinelle supports both glimpse and idutils. Glimpse had historically
provided the best performance, however recent benchmarks reveal idutils
is performing just as well. Due to some recent fixes however you however
will need at least coccinelle >= 1.0.6 if using idutils.
Coccinelle carries a script scripts/idutils_index.sh which creates the
idutils database with as follows:
mkid -i C --output .id-utils.index
If using just "--use-idutils" coccinelle expects your idutils database to be
on the top level of the kernel as a file named ".id-utils.index". If you do
not use this you can symlink your database file to it, or you can specify the
database file following the "--use-idutils" argument. Examples:
make SPFLAGS=--use-idutils coccicheck
This assumes you have $srctree/.id-utils.index, where $srctree is
the top level of the kernel.
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
Here you specify the full path of the idutils ID database. Using
.cocciconfig is possible, however given the order of precedence followed
by Coccinelle, and since the kernel now carries its own .cocciconfig,
you will need to use SPFLAGS to use idutils if desired.
v4:
o Recommend upgrade for using idutils with coccinelle due to some
recent fixes.
o Refer to using --print-options-only for testing what options are
picked up by .cocciconfig reading.
o Expand commit log considerably explaining *why* .cocconfig from
two precedence rules are used when using coccicheck, and how to
properly override these if needed.
o Expand Documentation/coccinelle.txt
v3: Expand commit log a bit more
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-30 01:14:56 +03:00
|
|
|
|
|
|
|
make SPFLAGS="--use-idutils /full-path/to/ID" coccicheck
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
See ``spatch --help`` to learn more about spatch options.
|
2010-10-13 02:49:07 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Note that the ``--use-glimpse`` and ``--use-idutils`` options
|
2013-06-20 16:00:19 +04:00
|
|
|
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.
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
SmPL patch specific options
|
|
|
|
---------------------------
|
2016-06-30 01:14:57 +03:00
|
|
|
|
|
|
|
SmPL patches can have their own requirements for options passed
|
2020-07-01 22:17:32 +03:00
|
|
|
to Coccinelle. SmPL patch-specific options can be provided by
|
2016-08-09 01:03:14 +03:00
|
|
|
providing them at the top of the SmPL patch, for instance::
|
2016-06-30 01:14:57 +03:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
// Options: --no-includes --include-headers
|
2016-06-30 01:14:57 +03:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
SmPL patch Coccinelle requirements
|
|
|
|
----------------------------------
|
2016-06-30 01:14:57 +03:00
|
|
|
|
|
|
|
As Coccinelle features get added some more advanced SmPL patches
|
|
|
|
may require newer versions of Coccinelle. If an SmPL patch requires
|
2020-07-01 22:17:32 +03:00
|
|
|
a minimum version of Coccinelle, this can be specified as follows,
|
2016-08-09 01:03:14 +03:00
|
|
|
as an example if requiring at least Coccinelle >= 1.0.5::
|
2016-06-30 01:14:57 +03:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
// Requires: 1.0.5
|
2016-06-30 01:14:57 +03:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Proposing new semantic patches
|
2020-06-05 06:04:05 +03:00
|
|
|
------------------------------
|
2010-06-06 19:15:02 +04:00
|
|
|
|
|
|
|
New semantic patches can be proposed and submitted by kernel
|
|
|
|
developers. For sake of clarity, they should be organized in the
|
2016-08-09 01:03:14 +03:00
|
|
|
sub-directories of ``scripts/coccinelle/``.
|
2010-06-06 19:15:02 +04:00
|
|
|
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Detailed description of the ``report`` mode
|
|
|
|
-------------------------------------------
|
|
|
|
|
|
|
|
``report`` generates a list in the following format::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
|
|
|
file:line:column-column: message
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Example
|
|
|
|
~~~~~~~
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Running::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2010-10-25 01:37:33 +04:00
|
|
|
make coccicheck MODE=report COCCI=scripts/coccinelle/api/err_cast.cocci
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
will execute the following part of the SmPL script::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
<smpl>
|
|
|
|
@r depends on !context && !patch && (org || report)@
|
|
|
|
expression x;
|
|
|
|
position p;
|
|
|
|
@@
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
ERR_PTR@p(PTR_ERR(x))
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
@script:python depends on report@
|
|
|
|
p << r.p;
|
|
|
|
x << r.x;
|
|
|
|
@@
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
msg="ERR_CAST can be used with %s" % (x)
|
|
|
|
coccilib.report.print_report(p[0], msg)
|
|
|
|
</smpl>
|
2010-06-06 19:15:02 +04:00
|
|
|
|
|
|
|
This SmPL excerpt generates entries on the standard output, as
|
2016-08-09 01:03:14 +03:00
|
|
|
illustrated below::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
/home/user/linux/crypto/ctr.c:188:9-16: ERR_CAST can be used with alg
|
|
|
|
/home/user/linux/crypto/authenc.c:619:9-16: ERR_CAST can be used with auth
|
|
|
|
/home/user/linux/crypto/xts.c:227:9-16: ERR_CAST can be used with alg
|
2010-06-06 19:15:02 +04:00
|
|
|
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Detailed description of the ``patch`` mode
|
|
|
|
------------------------------------------
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
When the ``patch`` mode is available, it proposes a fix for each problem
|
2010-06-06 19:15:02 +04:00
|
|
|
identified.
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Example
|
|
|
|
~~~~~~~
|
|
|
|
|
|
|
|
Running::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2010-10-25 01:37:33 +04:00
|
|
|
make coccicheck MODE=patch COCCI=scripts/coccinelle/api/err_cast.cocci
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
will execute the following part of the SmPL script::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
<smpl>
|
|
|
|
@ depends on !context && patch && !org && !report @
|
|
|
|
expression x;
|
|
|
|
@@
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
- ERR_PTR(PTR_ERR(x))
|
|
|
|
+ ERR_CAST(x)
|
|
|
|
</smpl>
|
2010-06-06 19:15:02 +04:00
|
|
|
|
|
|
|
This SmPL excerpt generates patch hunks on the standard output, as
|
2016-08-09 01:03:14 +03:00
|
|
|
illustrated below::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
diff -u -p a/crypto/ctr.c b/crypto/ctr.c
|
|
|
|
--- a/crypto/ctr.c 2010-05-26 10:49:38.000000000 +0200
|
|
|
|
+++ b/crypto/ctr.c 2010-06-03 23:44:49.000000000 +0200
|
|
|
|
@@ -185,7 +185,7 @@ static struct crypto_instance *crypto_ct
|
2010-06-06 19:15:02 +04:00
|
|
|
alg = crypto_attr_alg(tb[1], CRYPTO_ALG_TYPE_CIPHER,
|
|
|
|
CRYPTO_ALG_TYPE_MASK);
|
|
|
|
if (IS_ERR(alg))
|
2016-08-09 01:03:14 +03:00
|
|
|
- return ERR_PTR(PTR_ERR(alg));
|
|
|
|
+ return ERR_CAST(alg);
|
|
|
|
|
2010-06-06 19:15:02 +04:00
|
|
|
/* Block size must be >= 4 bytes. */
|
|
|
|
err = -EINVAL;
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Detailed description of the ``context`` mode
|
|
|
|
--------------------------------------------
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
``context`` highlights lines of interest and their context
|
2010-06-06 19:15:02 +04:00
|
|
|
in a diff-like style.
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
**NOTE**: The diff-like output generated is NOT an applicable patch. The
|
|
|
|
intent of the ``context`` mode is to highlight the important lines
|
|
|
|
(annotated with minus, ``-``) and gives some surrounding context
|
2010-06-06 19:15:02 +04:00
|
|
|
lines around. This output can be used with the diff mode of
|
|
|
|
Emacs to review the code.
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Example
|
|
|
|
~~~~~~~
|
|
|
|
|
|
|
|
Running::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2010-10-25 01:37:33 +04:00
|
|
|
make coccicheck MODE=context COCCI=scripts/coccinelle/api/err_cast.cocci
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
will execute the following part of the SmPL script::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
<smpl>
|
|
|
|
@ depends on context && !patch && !org && !report@
|
|
|
|
expression x;
|
|
|
|
@@
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
* ERR_PTR(PTR_ERR(x))
|
|
|
|
</smpl>
|
2010-06-06 19:15:02 +04:00
|
|
|
|
|
|
|
This SmPL excerpt generates diff hunks on the standard output, as
|
2016-08-09 01:03:14 +03:00
|
|
|
illustrated below::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
diff -u -p /home/user/linux/crypto/ctr.c /tmp/nothing
|
|
|
|
--- /home/user/linux/crypto/ctr.c 2010-05-26 10:49:38.000000000 +0200
|
|
|
|
+++ /tmp/nothing
|
|
|
|
@@ -185,7 +185,6 @@ static struct crypto_instance *crypto_ct
|
2010-06-06 19:15:02 +04:00
|
|
|
alg = crypto_attr_alg(tb[1], CRYPTO_ALG_TYPE_CIPHER,
|
|
|
|
CRYPTO_ALG_TYPE_MASK);
|
|
|
|
if (IS_ERR(alg))
|
2016-08-09 01:03:14 +03:00
|
|
|
- return ERR_PTR(PTR_ERR(alg));
|
|
|
|
|
2010-06-06 19:15:02 +04:00
|
|
|
/* Block size must be >= 4 bytes. */
|
|
|
|
err = -EINVAL;
|
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Detailed description of the ``org`` mode
|
|
|
|
----------------------------------------
|
|
|
|
|
|
|
|
``org`` generates a report in the Org mode format of Emacs.
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Example
|
|
|
|
~~~~~~~
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
Running::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2010-10-25 01:37:33 +04:00
|
|
|
make coccicheck MODE=org COCCI=scripts/coccinelle/api/err_cast.cocci
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
will execute the following part of the SmPL script::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
<smpl>
|
|
|
|
@r depends on !context && !patch && (org || report)@
|
|
|
|
expression x;
|
|
|
|
position p;
|
|
|
|
@@
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
ERR_PTR@p(PTR_ERR(x))
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
@script:python depends on org@
|
|
|
|
p << r.p;
|
|
|
|
x << r.x;
|
|
|
|
@@
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
msg="ERR_CAST can be used with %s" % (x)
|
|
|
|
msg_safe=msg.replace("[","@(").replace("]",")")
|
|
|
|
coccilib.org.print_todo(p[0], msg_safe)
|
|
|
|
</smpl>
|
2010-06-06 19:15:02 +04:00
|
|
|
|
|
|
|
This SmPL excerpt generates Org entries on the standard output, as
|
2016-08-09 01:03:14 +03:00
|
|
|
illustrated below::
|
2010-06-06 19:15:02 +04:00
|
|
|
|
2016-08-09 01:03:14 +03:00
|
|
|
* TODO [[view:/home/user/linux/crypto/ctr.c::face=ovl-face1::linb=188::colb=9::cole=16][ERR_CAST can be used with alg]]
|
|
|
|
* TODO [[view:/home/user/linux/crypto/authenc.c::face=ovl-face1::linb=619::colb=9::cole=16][ERR_CAST can be used with auth]]
|
|
|
|
* TODO [[view:/home/user/linux/crypto/xts.c::face=ovl-face1::linb=227::colb=9::cole=16][ERR_CAST can be used with alg]]
|