14 Aug, 2018
1 commit
-
If coccicheck fails, it should return an error code distinct from zero
to signal about an internal problem. Current code instead of exiting with
the tool's error code returns the error code of 'echo "coccicheck failed"'
which is almost always equals to zero, thus failing the original intention
of alerting about a problem. This patch fixes the code.Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Denis Efremov
Acked-by: Julia Lawall
Signed-off-by: Masahiro Yamada
01 Feb, 2018
1 commit
-
Correct spelling of "coccinelle".
Signed-off-by: Julia Lawall
Signed-off-by: Masahiro Yamada
23 Nov, 2017
1 commit
-
The command "make -j8 C=1 CHECK=scripts/coccicheck" produces
lots of "coccicheck failed" error messages.Julia Lawall explained the Coccinelle behavior as follows:
"The problem on the Coccinelle side is that it uses a subdirectory
with the name of the semantic patch to store standard output and
standard error for the different threads. I didn't want to use a
name with the pid, so that one could easily find this information
while Coccinelle is running. Normally the subdirectory is cleaned
up when Coccinelle completes, so there is only one of them at a time.
Maybe it is best to just add the pid. There is the risk that these
subdirectories will accumulate if Coccinelle crashes in a way such
that they don't get cleaned up, but Coccinelle could print a warning
if it detects this case, rather than failing."When scripts/coccicheck is used as CHECK tool and -j option is given
to Make, the whole of build process runs in parallel. So, multiple
processes try to get access to the same subdirectory.I notice spatch creates the subdirectory only when it runs in parallel
(i.e. --jobs is given and is greater than 1).Setting NPROC=1 is a reasonable solution; spatch does not create the
subdirectory. Besides, ONLINE=1 mode takes a single file input for
each spatch invocation, so there is no reason to parallelize it in
the first place.Signed-off-by: Masahiro Yamada
Acked-by: Julia Lawall
18 Nov, 2017
1 commit
-
…asahiroy/linux-kbuild
Pull Kbuild misc updates from Masahiro Yamada:
- Clean up and fix RPM package build
- Fix a warning in DEB package build
- Improve coccicheck script
- Improve some semantic patches
* tag 'kbuild-misc-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
docs: dev-tools: coccinelle: delete out of date wiki reference
coccinelle: orplus: reorganize to improve performance
coccinelle: use exists to improve efficiency
builddeb: Pass the kernel:debarch substvar to dpkg-genchanges
Coccinelle: use false positive annotation
coccinelle: fix verbose message about .cocci file being run
coccinelle: grep Options and Requires fields more precisely
Coccinelle: make DEBUG_FILE option more useful
coccinelle: api: detect identical chip data arrays
coccinelle: Improve setup_timer.cocci matching
Coccinelle: setup_timer: improve messages from setup_timer
kbuild: rpm-pkg: do not force -jN in submake
kbuild: rpm-pkg: keep spec file until make mrproper
kbuild: rpm-pkg: fix jobserver unavailable warning
kbuild: rpm-pkg: replace $RPM_BUILD_ROOT with %{buildroot}
kbuild: rpm-pkg: fix build error when CONFIG_MODULES is disabled
kbuild: rpm-pkg: refactor mkspec with here doc
kbuild: rpm-pkg: clean up mkspec
kbuild: rpm-pkg: install vmlinux.bz2 unconditionally
kbuild: rpm-pkg: remove ppc64 specific image handling
14 Nov, 2017
3 commits
-
If you run coccicheck with V=1 and COCCI=, you will see a strange
path to the semantic patch file. For example, run the following:$ make V=1 COCCI=scripts/coccinelle/free/kfree.cocci coccicheck
[ snip ]
The semantic patch that makes this report is available
in scriptcoccinelle/free/kfree.cocci.Notice "s/" was dropped from "scripts/coccinelle/free/kfree.cocci".
When running coccicheck without O=, $srctree is expanded to ".", which
represents one arbitrary character in the regular expression. Using
sed is not a good choice here. Strip $srctree/ simply without sed.Signed-off-by: Masahiro Yamada
Acked-by: Nicolas Palix -
Currently, the required version for badzero.cocci is picked up from
its "Comments:" line since it contains the word "Requires".Surprisingly, ld-version.sh can extract the version number from the
string "Requires Coccinelle version 1.0.0-rc20 or later", but this
expectation is fragile. Fix the .cocci file. I removed "-rc20"
because ld-version.sh cannot handle it.Make the coccicheck script to see exact patterns for "Options:" and
"Requires:" in order to avoid accidental matching to what just happens
to appear in comment lines.Signed-off-by: Masahiro Yamada
Acked-by: Julia Lawall
Acked-by: Nicolas Palix -
Make coccicheck checked for the existence of DEBUG_FILE on each semantic
patch, and bailed if it already existed. This meant that DEBUG_FILE was
useless for checking more than one semantic patch at a time. Now the check
is moved to the start of make coccicheck, and the 2> is changed to a 2>> to
append to the file on each semantic patch. Furthermore, the spatch command
that is run for each semantic patch is also added to the DEBUG_FILE, to
make clear what each stdout trace corresponds to.Signed-off-by: Julia Lawall
Signed-off-by: Masahiro Yamada
02 Nov, 2017
1 commit
-
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.By default all files without license information are under the default
license of the kernel, which is GPL version 2.Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if
Reviewed-by: Philippe Ombredanne
Reviewed-by: Thomas Gleixner
Signed-off-by: Greg Kroah-Hartman
11 Oct, 2016
1 commit
-
Use the current name (in a comment at the beginning of this script) for
the file which was converted to the documentation format "reStructuredText"
in August 2016.Fixes: 4b9033a33494 ("docs: sphinxify coccinelle.txt and add it to dev-tools")
Signed-off-by: Markus Elfring
Acked-by: Julia Lawall
Signed-off-by: Michal Marek
22 Jul, 2016
7 commits
-
Refer to the Documentation/coccinelle.txt and supplemental documentation
on the wiki:https://bottest.wiki.kernel.org/coccicheck
This page shall always refer to the linux-next iteration of scripts/coccicheck.
v4: only refer to the wiki as supplemental documentation, and also
update Documentation/coccinelle.txt.Signed-off-by: Luis R. Rodriguez
Acked-by: Nicolas Palix
Signed-off-by: Michal Marek -
Enable Coccinelle SmPL patches to require a specific version of
Coccinelle. In the event that the version does not match we just
inform the user, if the user asked to go through all SmPL patches
we just inform them of the need for a new version of coccinelle for
the SmPL patch and continue on with the rest.This uses the simple kernel scripts/ld-version.sh to create a weight
on the version provided by spatch. The -dirty attribute is ignored if
supplied, the benefit of scripts/ld-version.sh is it has a long history
and well tested.While at it, document the // Options stuff as well.
v4: Document // Options and // Requires as well on
Documentation/coccinelle.txt.Signed-off-by: Luis R. Rodriguez
Acked-by: Nicolas Palix
Signed-off-by: Michal Marek -
When debugging (using --profile or --show-trying) you want to
avoid supressing output, use --quiet instead. While at it, extend
documentation for SPFLAGS use.For instance one can use:
$ export COCCI=scripts/coccinelle/misc/irqf_oneshot.cocci
$ make coccicheck DEBUG_FILE="poo.err" MODE=report SPFLAGS="--profile --show-trying" M=./drivers/mfd/arizona-irq.cExpand Documentation/coccinelle.txt as well.
v4: expand Documentation/coccinelle.txt
v3: rebased, resolve conflicts, expand Documentation/coccinelle.txt
v2: use egrep instead of the *"=--option"* check, this doesn't work for
disjunctions.Signed-off-by: Luis R. Rodriguez
Acked-by: Julia Lawall
Signed-off-by: Michal Marek -
Enable to capture stderr via a DEBUG_FILE variable passed to
coccicheck. You can now do:$ rm -f cocci.err
$ export COCCI=scripts/coccinelle/free/kfree.cocci
$ make coccicheck MODE=report DEBUG_FILE=cocci.err
...
$ cat cocci.errThis will be come more useful once we add support to
use more things which would go into stderr, such as
profiling. That will be done separately in another
commit.Expand Documentation/coccinelle.txt with details.
Signed-off-by: Luis R. Rodriguez
Acked-by: Nicolas Palix
Signed-off-by: Michal Marek -
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.464sAfter:
real 16m22.435s
user 128m30.060s
sys 0m2.712sv4:
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/parmapSigned-off-by: Luis R. Rodriguez
Acked-by: Nicolas Palix
Signed-off-by: Michal Marek -
SPFLAGS is set early, it means that any heuristics done on
coccicheck cannot be overridden currently. Move SPFLAGS
after OPTIONS and set this at the end. This lets you override
any heuristics as coccinelle treats conflicts by only listening
to the last option that makes sense.v3: this patch was added in the v3 series
v4: Update Documentation/coccinelle.txt explaining how
SPFLAGS works as well.Signed-off-by: Luis R. Rodriguez
Acked-by: Nicolas Palix
Signed-off-by: Michal Marek -
This has no functional changes. This is being done
to enable us to later use spatch binary for some
flag checking for certain features early on.Signed-off-by: Luis R. Rodriguez
Acked-by: Nicolas Palix
Signed-off-by: Michal Marek
21 Jun, 2016
1 commit
-
Documentation/coccinelle.txt suggests using the SPFLAGS
make variable to pass additional options to spatch.Reorder the way SPFLAGS is added to FLAGS, to allow
for options in the SPFLAGS to override the default
--very-quiet option.Similarly, rearrage the FLAGS for org or report mode.
This allows for overriding of the default --no-show-diff
option through SPFLAGS.Signed-off-by: Deepa Dinamani
Cc: Gilles Muller
Acked-by: Nicolas Palix
Acked-by: Julia Lawall
Signed-off-by: Michal Marek
19 May, 2016
1 commit
-
By default, "seq" counts from 1, but processes were starting counting
from 0, so when interrupted, coccicheck would leave the 0th process
running.Signed-off-by: Kees Cook
Acked-by: Nicolas Palix
Acked-by: Julia Lawall
Signed-off-by: Michal Marek
27 Oct, 2015
1 commit
-
kbuild/gcc uses -include option to include files and -I to provide paths
for #include <> directive. In case of spatch latter option should be
prefixed with two -.Signed-off-by: Andrzej Hajda
Acked-by: Julia Lawall
Signed-off-by: Michal Marek
04 Jul, 2013
2 commits
-
The naming convention of options has changed one year ago.
The options have been recently updated in the cocci file
and in scripts/coccicheck. This patch also adds this information
in the documentation.Signed-off-by: Nicolas Palix
Signed-off-by: Michal Marek -
spatch has changed its option scheme.
E.g., --no_show_diff is now --no-show-diffThis patch updates:
- scripts/coccicheck
- Semantic patches under scripts/coccinelle/Signed-off-by: Nicolas Palix
Signed-off-by: Michal Marek
03 Jul, 2013
1 commit
-
This adds parallelism by default to the "coccicheck" target using
spatch's "-max" and "-index" arguments.Signed-off-by: Kees Cook
Signed-off-by: Nicolas Palix
Signed-off-by: Michal Marek
14 Jun, 2013
1 commit
-
It appears that the 'report' mode is the one always
provided by the semantic patches included in the kernel.
It is thus more natural to select it by default.The 'chain' mode is however kept and the 'patch' mode
is still the first tried in that case.Signed-off-by: Nicolas Palix
Signed-off-by: Michal Marek
08 Apr, 2013
4 commits
-
When the M variable is used, the -patch option should be given
to spatch. This patch fixes the case where C is used.Signed-off-by: Nicolas Palix
Signed-off-by: Michal Marek -
The SPFLAGS variable allows to pass additional options
to spatch, e.g. -use_glimpse.Signed-off-by: Nicolas Palix
Signed-off-by: Michal Marek -
The FLAGS variable is factorized independently of the ONLINE mode.
The OPTIONS variable is now based on LINUXINCLUDE and explicit
includes are thus removed.The format of the -I option differs between gcc and spatch.
The COCCIINCLUDE is used to adapt the format. This rewritting
needs bash.Signed-off-by: Nicolas Palix
Signed-off-by: Michal Marek -
A recent patch have introduce the VERBOSE variable and comments
now depend on it. However, the message printed for each cocci file
such not be printed when the ONLINE mode is active, whatever is
the value of VERBOSE.Signed-off-by: Nicolas Palix
Signed-off-by: Michal Marek
22 Feb, 2013
2 commits
-
On my system one of the tests failed with
"Fatal error: exception Failure("No OCaml compiler found! Install either ocamlopt or ocamlopt.opt")".Investigating such issues is easier if the executed command line is
being shown.Signed-off-by: Bernd Schubert
CC: Julia Lawall
Acked-by: Nicolas Palix
Signed-off-by: Michal Marek -
Do not run with verbosity on/off depending on the ONLINE variable,
which gets set with C=1 or C=2, but allow the user to set the
verbosity using kernel default make V= paramemter.
Verbosity is off by default now.Signed-off-by: Bernd Schubert
CC: Julia Lawall
Acked-by: Nicolas Palix
Signed-off-by: Michal Marek
11 Oct, 2012
1 commit
-
This adds a 'rep+ctxt' mode which prints the warning
message followed by the context.Signed-off-by: Nicolas Palix
Signed-off-by: Michal Marek
25 Feb, 2012
1 commit
-
This patch reverts a portion of d0bc1fb4 so that coccicheck will
work properly when C=1 or C=2.Reported-and-tested-by: Brice Goglin
Signed-off-by: Greg Dietsche
Signed-off-by: Julia Lawall
Signed-off-by: Michal Marek
15 Jan, 2012
1 commit
-
Examples:
make coccicheck M=drivers/net/wireless/
make coccicheck SUBDIRS=drivers/net/wireless/Version 2:
fix patch file names when using M=
tell coccinelle where the include files areVersion 3:
Add second include option to support out of tree development
Fix error messageSigned-off-by: Greg Dietsche
Acked-by: Julia Lawall
Signed-off-by: Michal Marek
28 Oct, 2010
1 commit
-
Change the message displayed to the user according
to the current mode used.Fix trailing white-space and spelling
Signed-off-by: Nicolas Palix
Signed-off-by: Michal Marek
13 Oct, 2010
3 commits
-
This allows to write the semantic patches with code sharing
for the matching parts.Signed-off-by: Nicolas Palix
Signed-off-by: Julia Lawall
Signed-off-by: Michal Marek -
spatch now returns -1 when a virtual rule (given with
-D on the command line) is not defined in the semantic patch.Using this spatch feature, coccicheck is now
tries several modes by default, in the order:
patch, report, context, orgSigned-off-by: Nicolas Palix
Signed-off-by: Julia Lawall
Signed-off-by: Michal Marek -
Improve user information with a new kind of comment
about semantic patch output.Fix spelling.
Signed-off-by: Nicolas Palix
Signed-off-by: Julia Lawall
Signed-off-by: Michal Marek
28 Jun, 2010
1 commit
-
This patch makes it possible to use the Coccinelle checker with the C
variable of the build system. To check only newly edited code, the
following command may be used:'make C={1,2} CHECK="scripts/coccicheck"'
This runs every semantic patch in scripts/coccinelle by default. The
COCCI variable may additionally be used to only apply a single
semantic patch.Signed-off-by: Nicolas Palix
Signed-off-by: Julia Lawall
Signed-off-by: Michal Marek
12 Jun, 2010
1 commit
-
A 'coccicheck' target is added. It can be called with four different
modes. Each one generates a different kind of output, i.e. context,
patch, org, report, according to the corresponding mode to be
activated.The new target calls the 'coccicheck' front-end in the 'scripts'
directory with the MODE argument. Every SmPL file in the
subdirectories of 'scripts/coccinelle' is then given to the front-end
and applied to the entire source tree.The four modes behave as follows:
'report' generates a list in the following format:
file:line:column-column: message'patch' proposes a fix, when possible.
'context' highlights lines of interest and their context in a
diff-like style. Lines of interest are indicated with '-'.'org' generates a report in the Org mode format of Emacs.
Signed-off-by: Nicolas Palix
Signed-off-by: Julia Lawall
Acked-by: Sam Ravnborg
Acked-by: Joerg Roedel
Signed-off-by: Michal Marek