Re: [PATCH] maint: use C99 initialization syntax for single-variable 'fo
From:
Collin Funk
Subject:
Re: [PATCH] maint: use C99 initialization syntax for single-variable 'for' loops
Date:
Mon, 17 Nov 2025 15:39:32 -0800
User-agent:
Gnus/5.13 (Gnus v5.13)
PƔdraig Brady <P@draigBrady.com> writes:
> On 17/11/2025 20:24, Collin Funk wrote:
>> PƔdraig Brady <P@draigBrady.com> writes:
>>
>>> On 17/11/2025 04:23, Collin Funk wrote:
>>>> @@ -724,7 +722,6 @@ digest_word_file (char const *file_name, WORD_TABLE
>>>> *table)
>>>> static void
>>>> find_occurs_in_text (int file_index)
>>>> {
>>>> - char *cursor; /* for scanning the source text */
>>>> char *scan; /* for scanning the source text also */
>>>
>>> Cool. Was the change automated with something like coccinelle etc.?
>>> One small s/ also// tweak in the last comment here would be good.
>>>
>>> Otherwise +1
>> It was done by hand, unfortunately.
>> Can coccinelle do this automatically? I have never used it.
> Well I've never used coccinelle in earnest actually.
> It seemed like it might have been potentially useful
> the last time I looked at doing something like this.
> Anyway I was just worried I was missing some new tool :)
No problem. I had a look at how git uses coccinelle and it seems quite
useful. They have a rule to prefer "if (ptr)" instead of
"if (ptr != NULL)", and the same for the inverse, for example [1].
I wouldn't mind converting/adding stuff in maint.mk to use new tools
like that, if it makes our lives easier.
An exception to that is formatters like 'indent' or 'clang-format'. With
those you run into annoying situations, e.g. if I upgrade to Fedora 44
before you do, we will likely have formatters that disagree with each
other.
Collin
[1] https://github.com/git/git/blob/master/contrib/coccinelle/equals-null.cocci