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 <s...@chromium.org>
Signed-off-by: Baruch Siach <bar...@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

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to