threads / bug / 58448

[BUG] Non-portable Construct Introduced in diagnose.c (dirent) at v2.38.0-rc0

Subject: [BUG] Non-portable Construct Introduced in diagnose.c (dirent) at v2.38.0-rc0

## tl;dr

4 messages between Sep 16, 2022 and Sep 17, 2022.

replies: 3people: 3as markdown or json

rsbecker@nexbridge.com· Sep 16, 2022, 23:04 UTC · lore

The dirent d_type field is not available on every system. This was introduced at 2.38.0-rc0 in diagnose.c

diagnose.c, line 79: error(1565): struct "dirent" has no field "d_type"
  		    e->d_type == DT_DIR && strlen(e->d_name) == 2 &&
(3 more issues in diagnose exist of this form).

The code should use the NO_D_TYPE_IN_DIRENT knob to detect whether this is an existing field as defined in cache.h.

This change breaks the build on NonStop systems (at least). I'm sorry I missed this during review.

Randall

-- Brief whoami: NonStop&UNIX developer since approximately UNIX(421664400) NonStop(211288444200000000) -- In real life, I talk too much.

Victoria Dye· Sep 16, 2022, 23:11 UTC · re: rsbecker@nexbridge.com · lore

Re: [BUG] Non-portable Construct Introduced in diagnose.c (dirent) at v2.38.0-rc0

rsbecker@nexbridge.com wrote:
Show 11 quoted lines
> The dirent d_type field is not available on every system. This was
> introduced at 2.38.0-rc0 in diagnose.c
> 
> diagnose.c, line 79: error(1565): struct "dirent" has no field "d_type"
> 
>   		    e->d_type == DT_DIR && strlen(e->d_name) == 2 &&
> 
> (3 more issues in diagnose exist of this form).
> 
> The code should use the  NO_D_TYPE_IN_DIRENT knob to detect whether this is
> an existing field as defined in cache.h.

Apologies for missing that, I'll try to send a patch fixing it either later today or sometime Monday.

Thanks, -Victoria

Show 14 quoted lines
> 
> This change breaks the build on NonStop systems (at least). I'm sorry I
> missed this during review.
> 
> Randall
> 
> --
> Brief whoami: NonStop&UNIX developer since approximately
> UNIX(421664400)
> NonStop(211288444200000000)
> -- In real life, I talk too much.
> 
> 
> 
rsbecker@nexbridge.com· Sep 16, 2022, 23:14 UTC · re: Victoria Dye · lore

RE: [BUG] Non-portable Construct Introduced in diagnose.c (dirent) at v2.38.0-rc0

On September 16, 2022 7:11 PM, Victoria Dye wrote:
Show 15 quoted lines
>rsbecker@nexbridge.com wrote:
>> The dirent d_type field is not available on every system. This was
>> introduced at 2.38.0-rc0 in diagnose.c
>>
>> diagnose.c, line 79: error(1565): struct "dirent" has no field "d_type"
>>
>>   		    e->d_type == DT_DIR && strlen(e->d_name) == 2 &&
>>
>> (3 more issues in diagnose exist of this form).
>>
>> The code should use the  NO_D_TYPE_IN_DIRENT knob to detect whether
>> this is an existing field as defined in cache.h.
>
>Apologies for missing that, I'll try to send a patch fixing it either later today or
>sometime Monday.
Thanks. If you need it tested in advance "in the wild", please let me know.

Regards, Randall

Junio C Hamano· Sep 17, 2022, 00:46 UTC · re: Victoria Dye · lore

Re: [BUG] Non-portable Construct Introduced in diagnose.c (dirent) at v2.38.0-rc0

Victoria Dye <vdye@github.com> writes:
Show 12 quoted lines
> rsbecker@nexbridge.com wrote:
>> The dirent d_type field is not available on every system. This was
>> introduced at 2.38.0-rc0 in diagnose.c
>> 
>> diagnose.c, line 79: error(1565): struct "dirent" has no field "d_type"
>> 
>>   		    e->d_type == DT_DIR && strlen(e->d_name) == 2 &&
>> 
>> (3 more issues in diagnose exist of this form).
>> 
>> The code should use the  NO_D_TYPE_IN_DIRENT knob to detect whether this is
>> an existing field as defined in cache.h.

Also, even if d_type member exists in the dirent struct, the value can be DT_UNKNOWN and the code should be prepared to fall back to do lstat() on the path in such a case.

dir.c::resolve_dtype() can be looked at for inspiration but only for inspiration and not for copying (because it is about tracked working tree paths, the function does a lot more than what diagnose.c wants to).

> Apologies for missing that, I'll try to send a patch fixing it either later
> today or sometime Monday.
Thanks, both of you.

← back to recent threads