mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/3] commands: test: simplify argv handling
@ 2023-07-04 11:29 Marco Felsch
  2023-07-04 11:29 ` [PATCH v2 2/3] commands: test: replace printf with pr_err Marco Felsch
  2023-07-04 11:29 ` [PATCH v2 3/3] commands: test: add based support for bash-test style Marco Felsch
  0 siblings, 2 replies; 5+ messages in thread
From: Marco Felsch @ 2023-07-04 11:29 UTC (permalink / raw)
  To: barebox

Decrement argc first before check the closing ']' to avoid the
*argv[argc - 1]. No functional change.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 commands/test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/commands/test.c b/commands/test.c
index c845cec017..c1b84c42ef 100644
--- a/commands/test.c
+++ b/commands/test.c
@@ -75,11 +75,11 @@ static int do_test(int argc, char *argv[])
 	struct stat statbuf;
 
 	if (*argv[0] == '[') {
-		if (*argv[argc - 1] != ']') {
+		argc--;
+		if (*argv[argc] != ']') {
 			printf("[: missing `]'\n");
 			return 1;
 		}
-		argc--;
 	}
 
 	/* args? */
-- 
2.39.2




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-07-04 12:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04 11:29 [PATCH v2 1/3] commands: test: simplify argv handling Marco Felsch
2023-07-04 11:29 ` [PATCH v2 2/3] commands: test: replace printf with pr_err Marco Felsch
2023-07-04 11:38   ` Sascha Hauer
2023-07-04 11:59     ` Marco Felsch
2023-07-04 11:29 ` [PATCH v2 3/3] commands: test: add based support for bash-test style Marco Felsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox