linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH] testsuite: fix 'format help' / validate number of arguments
Date: Tue, 23 Jun 2020 01:34:52 +0200	[thread overview]
Message-ID: <20200622233452.89993-1-luc.vanoostenryck@gmail.com> (raw)

The subcommand 'format help' is broken because the of the way
arguments are parsed without validating the number of arguments.

Fix this by parsing all arguments (even if there is only one)
and validate the number of arguments at the end of the loop.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 validation/test-suite | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/validation/test-suite b/validation/test-suite
index a22f70135fb3..d351ebf3c428 100755
--- a/validation/test-suite
+++ b/validation/test-suite
@@ -474,7 +474,7 @@ do_format()
 	linear=0
 	fail=0
 
-	while [ $# -gt 1 ] ; do
+	while [ $# -gt 0 ] ; do
 		case "$1" in
 		-a)
 			append=1 ;;
@@ -493,6 +493,11 @@ do_format()
 		continue
 	done
 
+	if [ $# -lt 1 -o $# -gt 3 ]; then
+		do_format_help
+		return 0
+	fi
+
 	arg_file "$1" || return 1
 
 	file="$1"
-- 
2.27.0

                 reply	other threads:[~2020-06-22 23:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200622233452.89993-1-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).