[PATCH v3 1/2] commands: test: simplify argv handling

Sascha Hauer sha at pengutronix.de
Thu Jul 27 23:41:00 PDT 2023


On Tue, Jul 04, 2023 at 02:16:25PM +0200, Marco Felsch wrote:
> 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>
> ---
> v3:
> - no changes
> v2:
> - no changes
> 
>  commands/test.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> 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
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list