This is an automated email from Gerrit.

Antonio Borneo ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/5025

-- gerrit

commit 166e5c583472d46a3152e11ac22eb0683c6aae3f
Author: Antonio Borneo <[email protected]>
Date:   Sat Mar 30 11:19:47 2019 +0100

    helper/command: handle empty "usage" with add_help_text/add_usage_text
    
    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 <[email protected]>

diff --git a/src/helper/command.c b/src/helper/command.c
index 869eff5..ec66c2d 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)

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to