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.sch...@siemens.com>
---
 devtools/checkpatches.sh | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

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>
-- 
2.35.1

Reply via email to