cert_create: update help message
The help message printed by the cert_create tool using the command
line option -h (or --help) does not correctly list all the available
command line options.
This patch reworks the print_help() function to print the help
messages in a data driven approach. For each command line option
registered, an optional help message can be specified, which will
be printed by print_help().
Help messages for the TBBR options (certificates, keys and images)
are also provided.
Fix a small bug in the short options string passed to getopt_long:
the ':' was missing in the '-a' option (this option must take an
argument).
Fixes ARM-software/tf-issues#337
Change-Id: I9d08c2dfd349022808fcc884724f677eefdc1452
diff --git a/tools/cert_create/src/key.c b/tools/cert_create/src/key.c
index 76d528b..a7ee759 100644
--- a/tools/cert_create/src/key.c
+++ b/tools/cert_create/src/key.c
@@ -194,6 +194,7 @@
int key_init(void)
{
+ cmd_opt_t cmd_opt;
key_t *key;
int rc = 0;
unsigned int i;
@@ -201,11 +202,12 @@
for (i = 0; i < num_keys; i++) {
key = &keys[i];
if (key->opt != NULL) {
- rc = cmd_opt_add(key->opt, required_argument,
- CMD_OPT_KEY);
- if (rc != 0) {
- break;
- }
+ cmd_opt.long_opt.name = key->opt;
+ cmd_opt.long_opt.has_arg = required_argument;
+ cmd_opt.long_opt.flag = NULL;
+ cmd_opt.long_opt.val = CMD_OPT_KEY;
+ cmd_opt.help_msg = key->help_msg;
+ cmd_opt_add(&cmd_opt);
}
}