Linux-Sparse Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] testsuite: fix 'format help' / validate number of arguments
@ 2020-06-22 23:34 Luc Van Oostenryck
  0 siblings, 0 replies; only message in thread
From: Luc Van Oostenryck @ 2020-06-22 23:34 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22 23:34 [PATCH] testsuite: fix 'format help' / validate number of arguments Luc Van Oostenryck

Linux-Sparse Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-sparse/0 linux-sparse/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-sparse linux-sparse/ https://lore.kernel.org/linux-sparse \
		linux-sparse@vger.kernel.org
	public-inbox-index linux-sparse

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-sparse


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git