From 8952cfe431cf5b1d615f054f698cd74034bd1385 Mon Sep 17 00:00:00 2001 From: Benjamin Philip Date: Wed, 7 Jan 2026 00:38:34 +0530 Subject: scripts: coccicheck: simplify debug file handling 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 Signed-off-by: Julia Lawall --- scripts/coccicheck | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'scripts') 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 -- cgit v1.2.3 From bb1c9ccf740eae3f116a2bb5d26c2bfb80cc8c7e Mon Sep 17 00:00:00 2001 From: Benjamin Philip Date: Wed, 7 Jan 2026 00:38:35 +0530 Subject: scripts: coccicheck: warn on unset debug file 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 Signed-off-by: Julia Lawall --- scripts/coccicheck | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'scripts') 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="' + echo '' DEBUG_FILE="/dev/null" fi -- cgit v1.2.3