u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools: kwboot: Allow to use -b without image path as the last getopt() option
@ 2022-02-07  9:12 Pali Rohár
  2022-02-07  9:22 ` Stefan Roese
  2022-02-10  8:19 ` Stefan Roese
  0 siblings, 2 replies; 3+ messages in thread
From: Pali Rohár @ 2022-02-07  9:12 UTC (permalink / raw)
  To: Marek Behún, Stefan Roese, Marcel Ziswiler; +Cc: u-boot

Currently it is possible to call "kwboot -b -t /dev/ttyUSB0" but not to
call "kwboot -b /dev/ttyUSB0".

Fix it by not trying to process the last argv[], which is non-getopt()
option (tty path) as the image path for -b.

Fixes: c513fe47dca2 ("tools: kwboot: Allow to use option -b without image path")
Reported-by: Marcel Ziswiler <marcel@ziswiler.com>
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marcel Ziswiler <marcel@ziswiler.com>
Tested-by: Marcel Ziswiler <marcel@ziswiler.com>
---
 tools/kwboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/kwboot.c b/tools/kwboot.c
index 7737188f0d0a..68c0ef1f1b07 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -1770,7 +1770,7 @@ main(int argc, char **argv)
 			bootmsg = kwboot_msg_boot;
 			if (prev_optind == optind)
 				goto usage;
-			if (argv[optind] && argv[optind][0] != '-')
+			if (optind < argc - 1 && argv[optind] && argv[optind][0] != '-')
 				imgpath = argv[optind++];
 			break;
 
-- 
2.20.1


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

* Re: [PATCH] tools: kwboot: Allow to use -b without image path as the last getopt() option
  2022-02-07  9:12 [PATCH] tools: kwboot: Allow to use -b without image path as the last getopt() option Pali Rohár
@ 2022-02-07  9:22 ` Stefan Roese
  2022-02-10  8:19 ` Stefan Roese
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Roese @ 2022-02-07  9:22 UTC (permalink / raw)
  To: Pali Rohár, Marek Behún, Marcel Ziswiler; +Cc: u-boot

On 2/7/22 10:12, Pali Rohár wrote:
> Currently it is possible to call "kwboot -b -t /dev/ttyUSB0" but not to
> call "kwboot -b /dev/ttyUSB0".
> 
> Fix it by not trying to process the last argv[], which is non-getopt()
> option (tty path) as the image path for -b.
> 
> Fixes: c513fe47dca2 ("tools: kwboot: Allow to use option -b without image path")
> Reported-by: Marcel Ziswiler <marcel@ziswiler.com>
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Reviewed-by: Marcel Ziswiler <marcel@ziswiler.com>
> Tested-by: Marcel Ziswiler <marcel@ziswiler.com>

Please correct me if I am wrong but AFAIU, this change makes it possible
to use kwboot to also boot images on some of the Armada 64 bit
platforms, as commented and tested by Marcel.

If this is the case, could you please update the documentation or at
least add a note with some comments to the commit text?

Thanks,
Stefan

> ---
>   tools/kwboot.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/kwboot.c b/tools/kwboot.c
> index 7737188f0d0a..68c0ef1f1b07 100644
> --- a/tools/kwboot.c
> +++ b/tools/kwboot.c
> @@ -1770,7 +1770,7 @@ main(int argc, char **argv)
>   			bootmsg = kwboot_msg_boot;
>   			if (prev_optind == optind)
>   				goto usage;
> -			if (argv[optind] && argv[optind][0] != '-')
> +			if (optind < argc - 1 && argv[optind] && argv[optind][0] != '-')
>   				imgpath = argv[optind++];
>   			break;
>   

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH] tools: kwboot: Allow to use -b without image path as the last getopt() option
  2022-02-07  9:12 [PATCH] tools: kwboot: Allow to use -b without image path as the last getopt() option Pali Rohár
  2022-02-07  9:22 ` Stefan Roese
@ 2022-02-10  8:19 ` Stefan Roese
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Roese @ 2022-02-10  8:19 UTC (permalink / raw)
  To: Pali Rohár, Marek Behún, Marcel Ziswiler; +Cc: u-boot

On 2/7/22 10:12, Pali Rohár wrote:
> Currently it is possible to call "kwboot -b -t /dev/ttyUSB0" but not to
> call "kwboot -b /dev/ttyUSB0".
> 
> Fix it by not trying to process the last argv[], which is non-getopt()
> option (tty path) as the image path for -b.
> 
> Fixes: c513fe47dca2 ("tools: kwboot: Allow to use option -b without image path")
> Reported-by: Marcel Ziswiler <marcel@ziswiler.com>
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Reviewed-by: Marcel Ziswiler <marcel@ziswiler.com>
> Tested-by: Marcel Ziswiler <marcel@ziswiler.com>

Applied to u-boot-marvell/master

Thanks,
Stefan

> ---
>   tools/kwboot.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/kwboot.c b/tools/kwboot.c
> index 7737188f0d0a..68c0ef1f1b07 100644
> --- a/tools/kwboot.c
> +++ b/tools/kwboot.c
> @@ -1770,7 +1770,7 @@ main(int argc, char **argv)
>   			bootmsg = kwboot_msg_boot;
>   			if (prev_optind == optind)
>   				goto usage;
> -			if (argv[optind] && argv[optind][0] != '-')
> +			if (optind < argc - 1 && argv[optind] && argv[optind][0] != '-')
>   				imgpath = argv[optind++];
>   			break;
>   

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

end of thread, other threads:[~2022-02-10  8:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07  9:12 [PATCH] tools: kwboot: Allow to use -b without image path as the last getopt() option Pali Rohár
2022-02-07  9:22 ` Stefan Roese
2022-02-10  8:19 ` Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).