scripts: fix checkpatch help
authorOlivier Matz <olivier.matz@6wind.com>
Tue, 16 Feb 2016 14:36:54 +0000 (15:36 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Thu, 24 Mar 2016 21:04:10 +0000 (22:04 +0100)
When started without defining DPDK_CHECKPATCH_PATH, the usage was not
displayed.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
scripts/checkpatches.sh

index afc611b..9d8541b 100755 (executable)
 # - DPDK_CHECKPATCH_PATH
 # - DPDK_CHECKPATCH_LINE_LENGTH
 . scripts/load-devel-config.sh
-if [ ! -x "$DPDK_CHECKPATCH_PATH" ] ; then
-       echo 'Cannot execute DPDK_CHECKPATCH_PATH' >&2
-       exit 1
-fi
 
 length=${DPDK_CHECKPATCH_LINE_LENGTH:-80}
 
@@ -51,7 +47,12 @@ SPLIT_STRING,LINE_SPACING,PARENTHESIS_ALIGNMENT,NETWORKING_BLOCK_COMMENT_STYLE,\
 NEW_TYPEDEFS,COMPARISON_TO_NULL"
 
 print_usage () {
-       echo "usage: $(basename $0) [-q] [-v] [patch1 [patch2] ...]]"
+       cat <<- END_OF_HELP
+       usage: $(basename $0) [-q] [-v] [patch1 [patch2] ...]]
+
+       Run Linux kernel checkpatch.pl with DPDK options.
+       The environment variable DPDK_CHECKPATCH_PATH must be set.
+       END_OF_HELP
 }
 
 quiet=false
@@ -66,6 +67,13 @@ while getopts hqv ARG ; do
 done
 shift $(($OPTIND - 1))
 
+if [ ! -x "$DPDK_CHECKPATCH_PATH" ] ; then
+       print_usage >&2
+       echo
+       echo 'Cannot execute DPDK_CHECKPATCH_PATH' >&2
+       exit 1
+fi
+
 status=0
 for p in "$@" ; do
        ! $verbose || printf '\n### %s\n\n' "$p"