Commit 399aacd6 authored by Sandrine Bailleux's avatar Sandrine Bailleux Committed by Dan Handley
Browse files

FIP tool: Fix error message for missing FIP filename

Previously to this path, the FIP tool used to print the following,
misleading error message when called without any argument or with
'--help' option:

  ERROR: Too many arguments

This patch fixes this behavior by printing the following error
message instead:

  ERROR: Missing FIP filename

If called with '--help', no error message is printed and only the
help message is displayed.

Change-Id: Ib281b056f5cd3bc2f66d98be0b0cb2a0aed7c6a8
parent 89f7b481
......@@ -509,11 +509,8 @@ static char *get_filename(int argc, char **argv, struct option *options)
/* Only one argument left then it is the filename.
* We dont expect any other options
*/
if (optind + 1 == argc) {
if (optind + 1 == argc)
filename = argv[optind];
} else {
printf("ERROR: Too many arguments.\n");
}
return filename;
}
......@@ -638,15 +635,13 @@ int main(int argc, char **argv)
* it causes a failure if bad options were provided.
*/
fip_filename = get_filename(argc, argv, long_options);
if (fip_filename == NULL) {
print_usage();
return 0;
}
/* Try to open the file and load it into memory */
status = parse_fip(fip_filename);
if (status != 0) {
return status;
if (fip_filename != NULL) {
status = parse_fip(fip_filename);
if (status != 0) {
return status;
}
}
/* Work through provided program arguments and perform actions */
......@@ -655,6 +650,12 @@ int main(int argc, char **argv)
return status;
};
if (fip_filename == NULL) {
printf("ERROR: Missing FIP filename\n");
print_usage();
return 0;
}
/* Processed all command line options. Create/update the package if
* required.
*/
......
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