Commit 15310348 authored by Simon Glass's avatar Simon Glass Committed by Tom Rini
Browse files

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: default avatarSimon Glass <sjg@chromium.org>
parent b0a487a4
...@@ -66,8 +66,9 @@ static void show_image_types(void) ...@@ -66,8 +66,9 @@ static void show_image_types(void)
fprintf(stderr, "\n"); 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" fprintf(stderr, "Usage: %s -l image\n"
" -l ==> list image header information\n", " -l ==> list image header information\n",
params.cmdname); params.cmdname);
...@@ -127,7 +128,7 @@ static void process_args(int argc, char **argv) ...@@ -127,7 +128,7 @@ static void process_args(int argc, char **argv)
case 'A': case 'A':
params.arch = genimg_get_arch_id(optarg); params.arch = genimg_get_arch_id(optarg);
if (params.arch < 0) if (params.arch < 0)
usage(); usage("Invalid architecture");
break; break;
case 'c': case 'c':
params.comment = optarg; params.comment = optarg;
...@@ -135,7 +136,7 @@ static void process_args(int argc, char **argv) ...@@ -135,7 +136,7 @@ static void process_args(int argc, char **argv)
case 'C': case 'C':
params.comp = genimg_get_comp_id(optarg); params.comp = genimg_get_comp_id(optarg);
if (params.comp < 0) if (params.comp < 0)
usage(); usage("Invalid compression type");
break; break;
case 'd': case 'd':
params.datafile = optarg; params.datafile = optarg;
...@@ -179,7 +180,7 @@ static void process_args(int argc, char **argv) ...@@ -179,7 +180,7 @@ static void process_args(int argc, char **argv)
case 'O': case 'O':
params.os = genimg_get_os_id(optarg); params.os = genimg_get_os_id(optarg);
if (params.os < 0) if (params.os < 0)
usage(); usage("Invalid operating system");
break; break;
case 'r': case 'r':
params.require_keys = 1; params.require_keys = 1;
...@@ -198,7 +199,7 @@ static void process_args(int argc, char **argv) ...@@ -198,7 +199,7 @@ static void process_args(int argc, char **argv)
params.type = genimg_get_type_id(optarg); params.type = genimg_get_type_id(optarg);
if (params.type < 0) { if (params.type < 0) {
show_image_types(); show_image_types();
usage(); usage("Invalid image type");
} }
break; break;
case 'v': case 'v':
...@@ -211,12 +212,12 @@ static void process_args(int argc, char **argv) ...@@ -211,12 +212,12 @@ static void process_args(int argc, char **argv)
params.xflag++; params.xflag++;
break; break;
default: default:
usage(); usage("Invalid option");
} }
} }
if (optind >= argc) if (optind >= argc)
usage(); usage("Missing output filename");
params.imagefile = argv[optind]; params.imagefile = argv[optind];
} }
...@@ -251,7 +252,7 @@ int main(int argc, char **argv) ...@@ -251,7 +252,7 @@ int main(int argc, char **argv)
*/ */
if (tparams->check_params) if (tparams->check_params)
if (tparams->check_params (&params)) if (tparams->check_params (&params))
usage(); usage("Bad parameters for image type");
if (!params.eflag) { if (!params.eflag) {
params.ep = params.addr; params.ep = params.addr;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment