{"thread":{"id":"65543","subject":"[PATCH] parse-options: fix sparse 'plain integer as NULL pointer'","startedAt":"2026-04-23T16:08:29Z","lastAt":"2026-04-29T05:13:17Z","messageCount":4,"participants":["Ramsay Jones","Junio C Hamano","Johannes Schindelin","Jiamu Sun"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"542204","messageId":"7aac2206-8b60-484f-a5f6-4943348ad3f6@ramsayjones.plus.com","threadId":"65543","inReplyTo":null,"subject":"[PATCH] parse-options: fix sparse 'plain integer as NULL pointer'","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2026-04-23T16:05:19Z","receivedAt":"2026-04-23T16:08:29Z","isPatch":true,"body":"\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n\nHi Jiamu Sun,\n\nIf you need to re-roll your 'js/parseopt-subcommand-autocorrection'\nbranch, could you please squash this into the patch corresponding\nto commit b9e6a2d30a (\"parseopt: autocorrect mistyped subcommands\",\n2026-04-23).\n\nThanks.\n\nATB,\nRamsay Jones\n\n parse-options.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/parse-options.c b/parse-options.c\nindex d60e7bd3c9..14f3f385eb 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -658,7 +658,7 @@ static const char *autocorrect_subcommand(const char *cmd,\n \n \tfor_each_string_list_item(cand, cmds) {\n \t\tif (starts_with(cand->string, cmd)) {\n-\t\t\tcand->util = 0;\n+\t\t\tcand->util = NULL;\n \t\t} else {\n \t\t\tint edit = levenshtein(cmd, cand->string,\n \t\t\t\t\t       0, 2, 1, 3) + 1;\n-- \n2.54.0\n"},{"id":"542236","messageId":"CAPc5daWZUJA0sEqS4Qk2vn5x+LNRgphxjzjdbcLFpEgS+69kUg@mail.gmail.com","threadId":"65543","inReplyTo":"7aac2206-8b60-484f-a5f6-4943348ad3f6@ramsayjones.plus.com","subject":"Re: [PATCH] parse-options: fix sparse 'plain integer as NULL pointer'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-04-24T02:47:56Z","receivedAt":"2026-04-24T02:48:16Z","isPatch":true,"body":"Another thing from GitHub CI\n\nhttps://github.com/git/git/actions/runs/24825391649/job/72659919418#step:9:144\n\n  Error: parse-options.c:680:30: comparison of integer expressions of\ndifferent signedness: 'unsigned int' and 'int' [-Werror=sign-compare]\n    680 |        (n < cmds->nr && best == (intptr_t)cmds->items[n].util);\n        |                              ^~\n\n2026年4月24日(金) 1:05 Ramsay Jones <ramsay@ramsayjones.plus.com>:\n>\n>\n> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n> ---\n>\n> Hi Jiamu Sun,\n>\n> If you need to re-roll your 'js/parseopt-subcommand-autocorrection'\n> branch, could you please squash this into the patch corresponding\n> to commit b9e6a2d30a (\"parseopt: autocorrect mistyped subcommands\",\n> 2026-04-23).\n>\n> Thanks.\n>\n> ATB,\n> Ramsay Jones\n>\n>  parse-options.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/parse-options.c b/parse-options.c\n> index d60e7bd3c9..14f3f385eb 100644\n> --- a/parse-options.c\n> +++ b/parse-options.c\n> @@ -658,7 +658,7 @@ static const char *autocorrect_subcommand(const char *cmd,\n>\n>         for_each_string_list_item(cand, cmds) {\n>                 if (starts_with(cand->string, cmd)) {\n> -                       cand->util = 0;\n> +                       cand->util = NULL;\n>                 } else {\n>                         int edit = levenshtein(cmd, cand->string,\n>                                                0, 2, 1, 3) + 1;\n> --\n> 2.54.0\n"},{"id":"542321","messageId":"d0357af8-ce70-77be-a885-070420d76c0b@gmx.de","threadId":"65543","inReplyTo":"CAPc5daWZUJA0sEqS4Qk2vn5x+LNRgphxjzjdbcLFpEgS+69kUg@mail.gmail.com","subject":"Re: [PATCH] parse-options: fix sparse 'plain integer as NULL pointer'","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2026-04-26T12:14:03Z","receivedAt":"2026-04-26T12:14:18Z","isPatch":true,"body":"Hi Junio,\n\nOn Sun, 26 Apr 2026, Junio C Hamano wrote:\n\n> Another thing from GitHub CI\n> \n> https://github.com/git/git/actions/runs/24825391649/job/72659919418#step:9:144\n> \n>   Error: parse-options.c:680:30: comparison of integer expressions of\n> different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]\n>     680 |        (n < cmds->nr && best == (intptr_t)cmds->items[n].util);\n>         |                              ^~\n\nIndeed. With this patch on top of Ramsay's fixup, it passes the build:\nhttps://github.com/dscho/git/actions/runs/24955417618\n\n-- snip --\nFrom: Johannes Schindelin <johannes.schindelin@gmx.de>\nDate: Sun, 26 Apr 2026 11:11:35 +0000\nSubject: [PATCH] fixup! parseopt: autocorrect mistyped subcommands\n\nFix a build warning in `linux32`: Change `best` from `unsigned int` to\n`intptr_t` to match the `(intptr_t)` casts it is compared against, fixing\na sign-compare warning on 32-bit platforms where `intptr_t` is `int`.\n\nAssisted-by: Claude Opus 4.6\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n parse-options.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/parse-options.c b/parse-options.c\nindex 14f3f385eb4..0ba6905fed5 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -648,7 +648,8 @@ static const char *autocorrect_subcommand(const char *cmd,\n \t\t\t\t\t  struct string_list *cmds)\n {\n \tstruct autocorrect autocorrect = { 0 };\n-\tunsigned int n = 0, best = 0;\n+\tunsigned int n = 0;\n+\tintptr_t best = 0;\n \tstruct string_list_item *cand;\n \n \tautocorrect_resolve(&autocorrect);\n-- snap --\n\nCiao,\nJohannes\n\n> \n> 2026年4月24日(金) 1:05 Ramsay Jones <ramsay@ramsayjones.plus.com>:\n> >\n> >\n> > Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n> > ---\n> >\n> > Hi Jiamu Sun,\n> >\n> > If you need to re-roll your 'js/parseopt-subcommand-autocorrection'\n> > branch, could you please squash this into the patch corresponding\n> > to commit b9e6a2d30a (\"parseopt: autocorrect mistyped subcommands\",\n> > 2026-04-23).\n> >\n> > Thanks.\n> >\n> > ATB,\n> > Ramsay Jones\n> >\n> >  parse-options.c | 2 +-\n> >  1 file changed, 1 insertion(+), 1 deletion(-)\n> >\n> > diff --git a/parse-options.c b/parse-options.c\n> > index d60e7bd3c9..14f3f385eb 100644\n> > --- a/parse-options.c\n> > +++ b/parse-options.c\n> > @@ -658,7 +658,7 @@ static const char *autocorrect_subcommand(const char *cmd,\n> >\n> >         for_each_string_list_item(cand, cmds) {\n> >                 if (starts_with(cand->string, cmd)) {\n> > -                       cand->util = 0;\n> > +                       cand->util = NULL;\n> >                 } else {\n> >                         int edit = levenshtein(cmd, cand->string,\n> >                                                0, 2, 1, 3) + 1;\n> > --\n> > 2.54.0\n> \n> \n"},{"id":"542458","messageId":"SY0P300MB0801A25D4414FCB5C522E407CE342@SY0P300MB0801.AUSP300.PROD.OUTLOOK.COM","threadId":"65543","inReplyTo":"d0357af8-ce70-77be-a885-070420d76c0b@gmx.de","subject":"Re: [PATCH] parse-options: fix sparse 'plain integer as NULL pointer'","fromName":"Jiamu Sun","fromEmail":"39@barroit.sh","sentAt":"2026-04-29T05:13:07Z","receivedAt":"2026-04-29T05:13:17Z","isPatch":true,"body":"On Sun, Apr 26, 2026 at 02:14:03PM +0200, Johannes Schindelin wrote:\n> Indeed. With this patch on top of Ramsay's fixup, it passes the build:\n> \n> Assisted-by: Claude Opus 4.6\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n>  parse-options.c | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n> \n> diff --git a/parse-options.c b/parse-options.c\n> index 14f3f385eb4..0ba6905fed5 100644\n> --- a/parse-options.c\n> +++ b/parse-options.c\n> @@ -648,7 +648,8 @@ static const char *autocorrect_subcommand(const char *cmd,\n>  \t\t\t\t\t  struct string_list *cmds)\n>  {\n>  \tstruct autocorrect autocorrect = { 0 };\n> -\tunsigned int n = 0, best = 0;\n> +\tunsigned int n = 0;\n> +\tintptr_t best = 0;\n>  \tstruct string_list_item *cand;\n>  \n>  \tautocorrect_resolve(&autocorrect);\n> -- snap --\n> \n> > > Ramsay Jones\n> > >\n> > >  parse-options.c | 2 +-\n> > >  1 file changed, 1 insertion(+), 1 deletion(-)\n> > >\n> > > diff --git a/parse-options.c b/parse-options.c\n> > > index d60e7bd3c9..14f3f385eb 100644\n> > > --- a/parse-options.c\n> > > +++ b/parse-options.c\n> > > @@ -658,7 +658,7 @@ static const char *autocorrect_subcommand(const char *cmd,\n> > >\n> > >         for_each_string_list_item(cand, cmds) {\n> > >                 if (starts_with(cand->string, cmd)) {\n> > > -                       cand->util = 0;\n> > > +                       cand->util = NULL;\n> > >                 } else {\n> > >                         int edit = levenshtein(cmd, cand->string,\n> > >                                                0, 2, 1, 3) + 1;\n> > > --\n> > > 2.54.0\n\nWill squash these in next re-roll.\n\nThanks everyone for catching these issues and providing the fixups.\n\n-- \nJiamu Sun <39@barroit.sh>\n          <sunjiamu@outlook.com>\n"}]}