Re: [PATCH 3/5] parseopt: autocorrect mistyped subcommands
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 9, 2026, 00:04 UTC
- Message-ID
- <xmqqo6kx98bi.fsf@gitster.g>
- In-Reply-To
- <SY0P300MB08010BFD00AA7C73503D8B92CE78A@SY0P300MB0801.AUSP300.PROD.OUTLOOK.COM>
Jiamu Sun <39@barroit.sh> writes:
Show 15 quoted lines
> +static const char *autocorrect_subcmd(const char *cmd,
> + struct string_list *cmds)
> +{
> + struct autocorr autocorr = { 0 };
> +
> + autocorr_resolve(&autocorr);
> +
> + if (autocorr.mode == AUTOCORR_NEVER ||
> + autocorr.mode == AUTOCORR_HINTONLY)
> + return NULL;
> +
> + unsigned int min = -1;
> + unsigned int ties = 0;
> + struct string_list_item *cand;
> + struct string_list_item *best = NULL;CodingGuidelines: -Wdeclaration-after-statement is here.
Using "-1" as "the maximum value this unsigned type can represent" is somewhat misleading. Can't we avoid that?