From a71410bacba960c09195ad1609f32d08fdb827c3 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 9 Oct 2024 13:54:24 +0000 Subject: [PATCH] cli: Declare command outside the switch statement Signed-off-by: Michael Tremer --- src/cli/lib/command.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cli/lib/command.c b/src/cli/lib/command.c index 28a13fb6f..5a9bcb20f 100644 --- a/src/cli/lib/command.c +++ b/src/cli/lib/command.c @@ -96,6 +96,8 @@ struct command_ctx { static error_t __command_parse(int key, char* arg, struct argp_state* state) { struct command_ctx* ctx = state->input; + const struct command* command = NULL; + // Just call the parse function if we don't have any commands if (!ctx->commands) { if (!ctx->parse) @@ -112,7 +114,7 @@ static error_t __command_parse(int key, char* arg, struct argp_state* state) { // Try to find a command case ARGP_KEY_ARG: - const struct command* command = ctx->command = command_find(ctx->commands, arg); + command = ctx->command = command_find(ctx->commands, arg); // Fail if the command wasn't found if (!command) { -- 2.47.2