devtools: give checkpatches.sh some way of finding the perl script

Message ID 20220907150144.5874-1-henning.schild@siemens.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series devtools: give checkpatches.sh some way of finding the perl script |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Henning Schild Sept. 7, 2022, 3:01 p.m. UTC
  Try and find the script in the sources of the currently running kernel
so that users do not have to specify DPDK_CHECKPATCH_PATH which might
well be the same location found by the educated guess.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 devtools/checkpatches.sh | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
  

Comments

Thomas Monjalon Oct. 11, 2022, 12:21 a.m. UTC | #1
07/09/2022 17:01, Henning Schild:
> Try and find the script in the sources of the currently running kernel
> so that users do not have to specify DPDK_CHECKPATCH_PATH which might
> well be the same location found by the educated guess.
> 
> Signed-off-by: Henning Schild <henning.schild@siemens.com>

Applied, thanks.
  

Patch

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 1edc5810ad10..03e791bd09d5 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -41,7 +41,8 @@  print_usage () {
 	usage: $(basename $0) [-h] [-q] [-v] [-nX|-r range|patch1 [patch2] ...]
 
 	Run Linux kernel checkpatch.pl with DPDK options.
-	The environment variable DPDK_CHECKPATCH_PATH must be set.
+	The environment variable DPDK_CHECKPATCH_PATH can be set, if not we will
+	try to find the script in the sources of the currently running kernel.
 
 	The patches to check can be from stdin, files specified on the command line,
 	latest git commits limited with -n option, or commits in the git range
@@ -256,10 +257,15 @@  done
 shift $(($OPTIND - 1))
 
 if [ ! -f "$DPDK_CHECKPATCH_PATH" ] || [ ! -x "$DPDK_CHECKPATCH_PATH" ] ; then
-	print_usage >&2
-	echo
-	echo 'Cannot execute DPDK_CHECKPATCH_PATH' >&2
-	exit 1
+	default_path="/lib/modules/$(uname -r)/source/scripts/checkpatch.pl"
+	if [ -f "$default_path" ] && [ -x "$default_path" ]; then
+		DPDK_CHECKPATCH_PATH="$default_path"
+	else
+		print_usage >&2
+		echo
+		echo 'Cannot execute DPDK_CHECKPATCH_PATH' >&2
+		exit 1
+	fi
 fi
 
 print_headline() { # <title>