All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mkimage: fix display of image types list
@ 2017-06-28 18:19 Baruch Siach
  2017-06-29 14:00 ` [U-Boot] " Tom Rini
  0 siblings, 1 reply; 3+ messages in thread
From: Baruch Siach @ 2017-06-28 18:19 UTC (permalink / raw)
  To: u-boot

Since commit 5b9d44df2307f (mkimage: Display a better list of available image
types) mkimage usage text suggest to "use -T to see a list of available image
types". Unfortunately, commit 02221f29deb8 (mkimage: Convert to use getopt())
broke that feature, because getopt() fails when -T has no option argument.

Make the -T option argument optional to restore the original behaviour.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 tools/mkimage.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/mkimage.c b/tools/mkimage.c
index d982bc5665f1..2c7801e8f836 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -144,7 +144,7 @@ static void process_args(int argc, char **argv)
 	int opt;
 
 	while ((opt = getopt(argc, argv,
-			     "a:A:b:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT:vVx")) != -1) {
+			     "a:A:b:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT::vVx")) != -1) {
 		switch (opt) {
 		case 'a':
 			params.addr = strtoull(optarg, &ptr, 16);
@@ -260,8 +260,9 @@ static void process_args(int argc, char **argv)
 			params.skipcpy = 1;
 			break;
 		case 'T':
-			type = genimg_get_type_id(optarg);
-			if (type < 0) {
+			if (optarg)
+				type = genimg_get_type_id(optarg);
+			if (optarg == NULL || type < 0) {
 				show_valid_options(IH_TYPE);
 				usage("Invalid image type");
 			}
-- 
2.11.0

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

* [U-Boot] mkimage: fix display of image types list
  2017-06-28 18:19 [U-Boot] [PATCH] mkimage: fix display of image types list Baruch Siach
@ 2017-06-29 14:00 ` Tom Rini
  2017-06-29 17:36   ` Baruch Siach
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Rini @ 2017-06-29 14:00 UTC (permalink / raw)
  To: u-boot

On Wed, Jun 28, 2017 at 09:19:43PM +0300, Baruch Siach wrote:

> Since commit 5b9d44df2307f (mkimage: Display a better list of available image
> types) mkimage usage text suggest to "use -T to see a list of available image
> types". Unfortunately, commit 02221f29deb8 (mkimage: Convert to use getopt())
> broke that feature, because getopt() fails when -T has no option argument.
> 
> Make the -T option argument optional to restore the original behaviour.
> 
> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>  tools/mkimage.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/mkimage.c b/tools/mkimage.c
> index d982bc5665f1..2c7801e8f836 100644
> --- a/tools/mkimage.c
> +++ b/tools/mkimage.c
> @@ -144,7 +144,7 @@ static void process_args(int argc, char **argv)
>  	int opt;
>  
>  	while ((opt = getopt(argc, argv,
> -			     "a:A:b:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT:vVx")) != -1) {
> +			     "a:A:b:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT::vVx")) != -1) {
>  		switch (opt) {
>  		case 'a':
>  			params.addr = strtoull(optarg, &ptr, 16);
> @@ -260,8 +260,9 @@ static void process_args(int argc, char **argv)
>  			params.skipcpy = 1;
>  			break;
>  		case 'T':
> -			type = genimg_get_type_id(optarg);
> -			if (type < 0) {
> +			if (optarg)
> +				type = genimg_get_type_id(optarg);
> +			if (optarg == NULL || type < 0) {
>  				show_valid_options(IH_TYPE);
>  				usage("Invalid image type");
>  			}

This breaks a large number of boards, for example try building
Lamobo_R1.  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170629/499f80fa/attachment.sig>

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

* [U-Boot] mkimage: fix display of image types list
  2017-06-29 14:00 ` [U-Boot] " Tom Rini
@ 2017-06-29 17:36   ` Baruch Siach
  0 siblings, 0 replies; 3+ messages in thread
From: Baruch Siach @ 2017-06-29 17:36 UTC (permalink / raw)
  To: u-boot

Hi Tom,

On Thu, Jun 29, 2017 at 10:00:55AM -0400, Tom Rini wrote:
> On Wed, Jun 28, 2017 at 09:19:43PM +0300, Baruch Siach wrote:
> > Since commit 5b9d44df2307f (mkimage: Display a better list of available image
> > types) mkimage usage text suggest to "use -T to see a list of available image
> > types". Unfortunately, commit 02221f29deb8 (mkimage: Convert to use getopt())
> > broke that feature, because getopt() fails when -T has no option argument.
> > 
> > Make the -T option argument optional to restore the original behaviour.
> > 
> > Cc: Simon Glass <sjg@chromium.org>
> > Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> > ---
> >  tools/mkimage.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/tools/mkimage.c b/tools/mkimage.c
> > index d982bc5665f1..2c7801e8f836 100644
> > --- a/tools/mkimage.c
> > +++ b/tools/mkimage.c
> > @@ -144,7 +144,7 @@ static void process_args(int argc, char **argv)
> >  	int opt;
> >  
> >  	while ((opt = getopt(argc, argv,
> > -			     "a:A:b:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT:vVx")) != -1) {
> > +			     "a:A:b:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT::vVx")) != -1) {
> >  		switch (opt) {
> >  		case 'a':
> >  			params.addr = strtoull(optarg, &ptr, 16);
> > @@ -260,8 +260,9 @@ static void process_args(int argc, char **argv)
> >  			params.skipcpy = 1;
> >  			break;
> >  		case 'T':
> > -			type = genimg_get_type_id(optarg);
> > -			if (type < 0) {
> > +			if (optarg)
> > +				type = genimg_get_type_id(optarg);
> > +			if (optarg == NULL || type < 0) {
> >  				show_valid_options(IH_TYPE);
> >  				usage("Invalid image type");
> >  			}
> 
> This breaks a large number of boards, for example try building
> Lamobo_R1.  Thanks!

Thanks for testing. The optional argument glibc extension to getopt() doesn't 
work as expected. I'll post different suggestion in v2 shortly.

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

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

end of thread, other threads:[~2017-06-29 17:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-28 18:19 [U-Boot] [PATCH] mkimage: fix display of image types list Baruch Siach
2017-06-29 14:00 ` [U-Boot] " Tom Rini
2017-06-29 17:36   ` Baruch Siach

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.