* [PATCH RESEND 1/3] scripts: coccicheck: simplify debug file handling
2026-01-06 19:08 [PATCH RESEND 0/3] scripts: coccicheck: document debug log handling Benjamin Philip
@ 2026-01-06 19:08 ` Benjamin Philip
2026-01-06 19:08 ` [PATCH RESEND 2/3] scripts: coccicheck: warn on unset debug file Benjamin Philip
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Benjamin Philip @ 2026-01-06 19:08 UTC (permalink / raw)
To: Julia Lawall, Nicolas Palix, Jonathan Corbet
Cc: cocci, workflows, linux-doc, linux-kernel, Benjamin Philip
This commit separates handling unset files and pre-existing files. It
also eliminates a duplicated check for unset files in run_cmd_parmap().
Signed-off-by: Benjamin Philip <benjamin.philip495@gmail.com>
---
scripts/coccicheck | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/scripts/coccicheck b/scripts/coccicheck
index 89d591af5f3e..2efb74afef2b 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -138,7 +138,7 @@ run_cmd_parmap() {
if [ $VERBOSE -ne 0 ] ; then
echo "Running ($NPROC in parallel): $@"
fi
- if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then
+ if [ "$DEBUG_FILE" != "/dev/null" ]; then
echo $@>>$DEBUG_FILE
$@ 2>>$DEBUG_FILE
else
@@ -259,13 +259,13 @@ coccinelle () {
}
-if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then
- if [ -f $DEBUG_FILE ]; then
- echo "Debug file $DEBUG_FILE exists, bailing"
- exit
- fi
-else
- DEBUG_FILE="/dev/null"
+if [ "$DEBUG_FILE" = "" ]; then
+ DEBUG_FILE="/dev/null"
+fi
+
+if [ -f $DEBUG_FILE ]; then
+ echo "Debug file $DEBUG_FILE exists, bailing"
+ exit
fi
if [ "$COCCI" = "" ] ; then
--
2.52.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH RESEND 2/3] scripts: coccicheck: warn on unset debug file
2026-01-06 19:08 [PATCH RESEND 0/3] scripts: coccicheck: document debug log handling Benjamin Philip
2026-01-06 19:08 ` [PATCH RESEND 1/3] scripts: coccicheck: simplify debug file handling Benjamin Philip
@ 2026-01-06 19:08 ` Benjamin Philip
2026-01-06 19:08 ` [PATCH RESEND 3/3] Documentation: Coccinelle: document debug log handling Benjamin Philip
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Benjamin Philip @ 2026-01-06 19:08 UTC (permalink / raw)
To: Julia Lawall, Nicolas Palix, Jonathan Corbet
Cc: cocci, workflows, linux-doc, linux-kernel, Benjamin Philip
coccicheck prints debug logs to stdout unless a debug file has been set.
This makes it hard to read coccinelle's suggested changes, especially
for someone new to coccicheck.
From this commit, we warn about this behaviour from within the script on
an unset debug file. Explicitly setting the debug file to /dev/null
suppresses the warning while keeping the default.
Signed-off-by: Benjamin Philip <benjamin.philip495@gmail.com>
---
scripts/coccicheck | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/scripts/coccicheck b/scripts/coccicheck
index 2efb74afef2b..8dd766009de1 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -260,6 +260,11 @@ coccinelle () {
}
if [ "$DEBUG_FILE" = "" ]; then
+ echo 'You have not explicitly specified the debug file to use.'
+ echo 'Using default "/dev/null" as debug file.'
+ echo 'Debug logs will be printed to stdout.'
+ echo 'You can specify the debug file with "make coccicheck DEBUG_FILE=<debug_file>"'
+ echo ''
DEBUG_FILE="/dev/null"
fi
--
2.52.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH RESEND 3/3] Documentation: Coccinelle: document debug log handling
2026-01-06 19:08 [PATCH RESEND 0/3] scripts: coccicheck: document debug log handling Benjamin Philip
2026-01-06 19:08 ` [PATCH RESEND 1/3] scripts: coccicheck: simplify debug file handling Benjamin Philip
2026-01-06 19:08 ` [PATCH RESEND 2/3] scripts: coccicheck: warn on unset debug file Benjamin Philip
@ 2026-01-06 19:08 ` Benjamin Philip
2026-01-20 12:32 ` [cocci] [PATCH RESEND 0/3] scripts: coccicheck: " Julia Lawall
2026-02-21 16:40 ` Julia Lawall
4 siblings, 0 replies; 6+ messages in thread
From: Benjamin Philip @ 2026-01-06 19:08 UTC (permalink / raw)
To: Julia Lawall, Nicolas Palix, Jonathan Corbet
Cc: cocci, workflows, linux-doc, linux-kernel, Benjamin Philip
The current debug documentation does not mention that logs are printed
to stdout unless DEBUG_FILE is set. It also doesn't mention that
Coccinelle cannot overwrite debug files.
Document this behaviour in the examples and reference it in the
debugging section.
Signed-off-by: Benjamin Philip <benjamin.philip495@gmail.com>
---
Documentation/dev-tools/coccinelle.rst | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/Documentation/dev-tools/coccinelle.rst b/Documentation/dev-tools/coccinelle.rst
index 6e70a1e9a3c0..c714780d458a 100644
--- a/Documentation/dev-tools/coccinelle.rst
+++ b/Documentation/dev-tools/coccinelle.rst
@@ -127,6 +127,18 @@ To enable verbose messages set the V= variable, for example::
make coccicheck MODE=report V=1
+By default, coccicheck will print debug logs to stdout and redirect stderr to
+/dev/null. This can make coccicheck output difficult to read and understand.
+Debug and error messages can instead be written to a debug file instead by
+setting the ``DEBUG_FILE`` variable::
+
+ make coccicheck MODE=report DEBUG_FILE="cocci.log"
+
+Coccinelle cannot overwrite a debug file. Instead of repeatedly deleting a log
+file, you could include the datetime in the debug file name::
+
+ make coccicheck MODE=report DEBUG_FILE="cocci-$(date -Iseconds).log"
+
Coccinelle parallelization
--------------------------
@@ -208,11 +220,10 @@ include options matching the options used when we compile the kernel.
You can learn what these options are by using V=1; you could then
manually run Coccinelle with debug options added.
-Alternatively you can debug running Coccinelle against SmPL patches
-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
-can specify the ``DEBUG_FILE="file.txt"`` option to coccicheck. For
-instance::
+An easier approach to debug running Coccinelle against SmPL patches is to ask
+coccicheck to redirect stderr to a debug file. As mentioned in the examples, by
+default stderr is redirected to /dev/null; if you'd like to capture stderr you
+can specify the ``DEBUG_FILE="file.txt"`` option to coccicheck. For instance::
rm -f cocci.err
make coccicheck COCCI=scripts/coccinelle/free/kfree.cocci MODE=report DEBUG_FILE=cocci.err
--
2.52.0
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [cocci] [PATCH RESEND 0/3] scripts: coccicheck: document debug log handling
2026-01-06 19:08 [PATCH RESEND 0/3] scripts: coccicheck: document debug log handling Benjamin Philip
` (2 preceding siblings ...)
2026-01-06 19:08 ` [PATCH RESEND 3/3] Documentation: Coccinelle: document debug log handling Benjamin Philip
@ 2026-01-20 12:32 ` Julia Lawall
2026-02-21 16:40 ` Julia Lawall
4 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2026-01-20 12:32 UTC (permalink / raw)
To: Benjamin Philip
Cc: Julia Lawall, Nicolas Palix, Jonathan Corbet, cocci, workflows,
linux-doc, linux-kernel
On Wed, 7 Jan 2026, Benjamin Philip wrote:
> Currently coccicheck prints debug logs to stdout unless a debug file has been
> set. This makes it hard to read coccinelle's suggested changes, especially for
> someone new to coccicheck.
>
> This patchset documents this behaviour in both the coccicheck script as well as
> in the dev-tools documentation. Additionally, it simplifies some of the logic
> for handling debug files.
>
> Benjamin Philip (3):
> scripts: coccicheck: simplify debug file handling
> scripts: coccicheck: warn on unset debug file
> Documentation: Coccinelle: document debug log handling
>
> Documentation/dev-tools/coccinelle.rst | 21 ++++++++++++++++-----
> scripts/coccicheck | 21 +++++++++++++--------
> 2 files changed, 29 insertions(+), 13 deletions(-)
Thanks for the update. I will try to get this in for the next release.
julia
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [cocci] [PATCH RESEND 0/3] scripts: coccicheck: document debug log handling
2026-01-06 19:08 [PATCH RESEND 0/3] scripts: coccicheck: document debug log handling Benjamin Philip
` (3 preceding siblings ...)
2026-01-20 12:32 ` [cocci] [PATCH RESEND 0/3] scripts: coccicheck: " Julia Lawall
@ 2026-02-21 16:40 ` Julia Lawall
4 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2026-02-21 16:40 UTC (permalink / raw)
To: Benjamin Philip
Cc: Julia Lawall, Nicolas Palix, Jonathan Corbet, cocci, workflows,
linux-doc, linux-kernel
On Wed, 7 Jan 2026, Benjamin Philip wrote:
> Currently coccicheck prints debug logs to stdout unless a debug file has been
> set. This makes it hard to read coccinelle's suggested changes, especially for
> someone new to coccicheck.
>
> This patchset documents this behaviour in both the coccicheck script as well as
> in the dev-tools documentation. Additionally, it simplifies some of the logic
> for handling debug files.
All applied, thanks.
julia
>
> Benjamin Philip (3):
> scripts: coccicheck: simplify debug file handling
> scripts: coccicheck: warn on unset debug file
> Documentation: Coccinelle: document debug log handling
>
> Documentation/dev-tools/coccinelle.rst | 21 ++++++++++++++++-----
> scripts/coccicheck | 21 +++++++++++++--------
> 2 files changed, 29 insertions(+), 13 deletions(-)
>
> --
> 2.52.0
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread