diff options
author | Simon Glass <sjg@chromium.org> | 2016-02-22 22:55:37 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-03-14 14:19:11 -0400 |
commit | 1531034831b3098634b524b7e244f577fae21312 (patch) | |
tree | 9633d88ca281c99ac465732610fdc5f439e62eb0 /tools | |
parent | b0a487a4eb6c1e2214022f927cb3229f2323db44 (diff) | |
download | u-boot-imx-1531034831b3098634b524b7e244f577fae21312.zip u-boot-imx-1531034831b3098634b524b7e244f577fae21312.tar.gz u-boot-imx-1531034831b3098634b524b7e244f577fae21312.tar.bz2 |
mkimage: Show an error message when usage() is called
Sometimes incorrect arguments are supplied but the reason is not obvious to
the user. Add some helpful messages.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/mkimage.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/tools/mkimage.c b/tools/mkimage.c index 1cc3a63..bcf2272 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -66,8 +66,9 @@ static void show_image_types(void) fprintf(stderr, "\n"); } -static void usage(void) +static void usage(const char *msg) { + fprintf(stderr, "Error: %s\n", msg); fprintf(stderr, "Usage: %s -l image\n" " -l ==> list image header information\n", params.cmdname); @@ -127,7 +128,7 @@ static void process_args(int argc, char **argv) case 'A': params.arch = genimg_get_arch_id(optarg); if (params.arch < 0) - usage(); + usage("Invalid architecture"); break; case 'c': params.comment = optarg; @@ -135,7 +136,7 @@ static void process_args(int argc, char **argv) case 'C': params.comp = genimg_get_comp_id(optarg); if (params.comp < 0) - usage(); + usage("Invalid compression type"); break; case 'd': params.datafile = optarg; @@ -179,7 +180,7 @@ static void process_args(int argc, char **argv) case 'O': params.os = genimg_get_os_id(optarg); if (params.os < 0) - usage(); + usage("Invalid operating system"); break; case 'r': params.require_keys = 1; @@ -198,7 +199,7 @@ static void process_args(int argc, char **argv) params.type = genimg_get_type_id(optarg); if (params.type < 0) { show_image_types(); - usage(); + usage("Invalid image type"); } break; case 'v': @@ -211,12 +212,12 @@ static void process_args(int argc, char **argv) params.xflag++; break; default: - usage(); + usage("Invalid option"); } } if (optind >= argc) - usage(); + usage("Missing output filename"); params.imagefile = argv[optind]; } @@ -251,7 +252,7 @@ int main(int argc, char **argv) */ if (tparams->check_params) if (tparams->check_params (¶ms)) - usage(); + usage("Bad parameters for image type"); if (!params.eflag) { params.ep = params.addr; |