X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fhelper%2Fcommand.c;h=ec66c2d2982e2050621a05496a04f93d7d831e3e;hb=c19de41a0f49ee11eb474c51dc243383047bd663;hp=7a3c2d4fe47a6b129d55bdf3e76b7533c5b493b1;hpb=d470b84b51c89ecbc541081cc2cfa1744437dfa3;p=openocd.git diff --git a/src/helper/command.c b/src/helper/command.c index 7a3c2d4fe4..ec66c2d298 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -1119,7 +1119,7 @@ int help_add_command(struct command_context *cmd_ctx, struct command *parent, .name = cmd_name, .mode = COMMAND_ANY, .help = help_text, - .usage = usage, + .usage = usage ? : "", }; nc = register_command(cmd_ctx, parent, &cr); if (NULL == nc) { @@ -1144,8 +1144,9 @@ int help_add_command(struct command_context *cmd_ctx, struct command *parent, if (usage) { bool replaced = false; if (nc->usage) { + if (*nc->usage) + replaced = true; free(nc->usage); - replaced = true; } nc->usage = strdup(usage); if (replaced) @@ -1294,6 +1295,7 @@ static const struct command_registration command_builtin_handlers[] = { .mode = COMMAND_ANY, .help = "core command group (introspection)", .chain = command_subcommand_handlers, + .usage = "", }, COMMAND_REGISTRATION_DONE };