helper/command: handle empty "usage" with add_help_text/add_usage_text 25/5025/2
authorAntonio Borneo <borneo.antonio@gmail.com>
Sat, 30 Mar 2019 10:19:47 +0000 (11:19 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Sun, 7 Apr 2019 07:19:52 +0000 (08:19 +0100)
By using the command "add_help_text" to add a help text to a TCL
procedure it implicitly creates a new command_registration struct
that has field .usage set to NULL. This triggers a debug message
BUG: command '%s' does not have the '.usage' field filled out

Use an empty string if usage field is NULL.

Plus, do not annoy the user with a LOG_INFO when the command
"add_usage_text" replaces an empty usage.

Change-Id: I4a72646e0fb704ba354f938d774055540cde3967
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5025
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
src/helper/command.c

index 869eff559cdd0836b760744bd1052439e093807a..ec66c2d2982e2050621a05496a04f93d7d831e3e 100644 (file)
@@ -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,
                        .name = cmd_name,
                        .mode = COMMAND_ANY,
                        .help = help_text,
-                       .usage = usage,
+                       .usage = usage ? : "",
                };
                nc = register_command(cmd_ctx, parent, &cr);
                if (NULL == nc) {
                };
                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 (usage) {
                bool replaced = false;
                if (nc->usage) {
+                       if (*nc->usage)
+                               replaced = true;
                        free(nc->usage);
                        free(nc->usage);
-                       replaced = true;
                }
                nc->usage = strdup(usage);
                if (replaced)
                }
                nc->usage = strdup(usage);
                if (replaced)

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)