refactor command_new to use command_registration
authorZachary T Welch <zw@superlucidity.net>
Mon, 23 Nov 2009 23:01:12 +0000 (15:01 -0800)
committerZachary T Welch <zw@superlucidity.net>
Wed, 25 Nov 2009 05:37:37 +0000 (21:37 -0800)
Save stack space: use a struct.  Makes it easier to add new parameters.

src/helper/command.c

index dd109657069aa349b5f1e874d5577c90aa9e38e7..8d710c9986e465beb6b80214e1515994aeed377e 100644 (file)
@@ -238,23 +238,21 @@ static struct command **command_list_for_parent(
 }
 
 static struct command *command_new(struct command_context *cmd_ctx,
-               struct command *parent, const char *name,
-               command_handler_t handler, enum command_mode mode,
-               const char *help, const char *usage)
+               struct command *parent, const struct command_registration *cr)
 {
-       assert(name);
+       assert(cr->name);
 
        struct command *c = malloc(sizeof(struct command));
        memset(c, 0, sizeof(struct command));
 
-       c->name = strdup(name);
-       if (help)
-               c->help = strdup(help);
-       if (usage)
-               c->usage = strdup(usage);
+       c->name = strdup(cr->name);
+       if (cr->help)
+               c->help = strdup(cr->help);
+       if (cr->usage)
+               c->usage = strdup(cr->usage);
        c->parent = parent;
-       c->handler = handler;
-       c->mode = mode;
+       c->handler = cr->handler;
+       c->mode = cr->mode;
 
        command_add_child(command_list_for_parent(cmd_ctx, parent), c);
 
@@ -328,7 +326,7 @@ struct command* register_command(struct command_context *context,
                return c;
        }
 
-       c = command_new(context, parent, name, cr->handler, cr->mode, cr->help, cr->usage);
+       c = command_new(context, parent, cr);
        /* if allocation failed or it is a placeholder (no handler), we're done */
        if (NULL == c || NULL == c->handler)
                return c;

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)