From: Michael Tremer Date: Wed, 9 Oct 2024 13:54:24 +0000 (+0000) Subject: cli: Declare command outside the switch statement X-Git-Tag: 0.9.30~1113 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a71410bacba960c09195ad1609f32d08fdb827c3;p=pakfire.git cli: Declare command outside the switch statement Signed-off-by: Michael Tremer --- 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) {