From 399aacd68f64a98fb9c01d2f63502b869b0e7f70 Mon Sep 17 00:00:00 2001 From: Sandrine Bailleux Date: Wed, 19 Mar 2014 13:39:52 +0000 Subject: [PATCH] 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 --- tools/fip_create/fip_create.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/fip_create/fip_create.c b/tools/fip_create/fip_create.c index a0fdd0abf..71ee1de93 100644 --- a/tools/fip_create/fip_create.c +++ b/tools/fip_create/fip_create.c @@ -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. */