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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux