[PATCH v2 1/3] commands: test: simplify argv handling
Marco Felsch
m.felsch at pengutronix.de
Tue Jul 4 04:29:19 PDT 2023
Decrement argc first before check the closing ']' to avoid the
*argv[argc - 1]. No functional change.
Signed-off-by: Marco Felsch <m.felsch at 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
More information about the barebox
mailing list