Re: [PATCH] cocci: do not directly access the .d_type member in struct dirent
- From
Collin Funk <collin.funk1@gmail.com>
- Date
- Jun 18, 2025, 18:31 UTC
- Message-ID
- <87ldposxyk.fsf@gmail.com>
- In-Reply-To
- <xmqq4iwcgbzb.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 10 quoted lines
> In "struct dirent", the presence of the .d_type member should not be > assumed and the code should instead use DTYPE() macro, with possibly > a fallback check to determine the type of the file. > > Add a rule to catch direct access to the .d_type member and use > DTYPE() macro instead, except in the emulation code paths that work > on platforms that do have the member. This is probably not sufficient > to notice the lack of necessary fallback code. > > Signed-off-by: Junio C Hamano <gitster@pobox.com>
This change looks good to me. Atleast it will catch code that fails to build on niche platforms, even if it cannot validate existing backup code.
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
Your fix for the 'git diff --no-index' looks correct [1]. I'll build libcurl on an AIX machine I have access to in order to test (not an administrator on it).
Collin
[1] https://lore.kernel.org/git/xmqqwm98ewsd.fsf@gitster.g/T/#m4fc1f0ddf1730ffb025e37d523035bd9f6cddfae