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

4 messages from 2022-09-16 to 2022-09-17. Participants: rsbecker@nexbridge.com, Victoria Dye, Junio C Hamano.
Thread: https://gitlist.dev/t/58448

## rsbecker@nexbridge.com, 2022-09-16 23:04

Subject: [BUG] Non-portable Construct Introduced in diagnose.c (dirent) at v2.38.0-rc0
Message-ID: <011001d8ca20$bc4d81f0$34e885d0$@nexbridge.com>
URL: https://gitlist.dev/e/011001d8ca20%24bc4d81f0%2434e885d0%24%40nexbridge.com

```
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, 2022-09-16 23:11

Subject: Re: [BUG] Non-portable Construct Introduced in diagnose.c (dirent) at v2.38.0-rc0
Message-ID: <5d02d3b8-dc79-a2d8-f5e1-129d2228ff23@github.com>
URL: https://gitlist.dev/e/5d02d3b8-dc79-a2d8-f5e1-129d2228ff23%40github.com
In-Reply-To: <011001d8ca20$bc4d81f0$34e885d0$@nexbridge.com>

```
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,
-Victoria

> 
> 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, 2022-09-16 23:14

Subject: RE: [BUG] Non-portable Construct Introduced in diagnose.c (dirent) at v2.38.0-rc0
Message-ID: <011101d8ca22$04b68940$0e239bc0$@nexbridge.com>
URL: https://gitlist.dev/e/011101d8ca22%2404b68940%240e239bc0%24%40nexbridge.com
In-Reply-To: <5d02d3b8-dc79-a2d8-f5e1-129d2228ff23@github.com>

```
On September 16, 2022 7:11 PM, Victoria Dye wrote:
>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, 2022-09-17 00:46

Subject: Re: [BUG] Non-portable Construct Introduced in diagnose.c (dirent) at v2.38.0-rc0
Message-ID: <xmqqtu56eskk.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqtu56eskk.fsf%40gitster.g
In-Reply-To: <5d02d3b8-dc79-a2d8-f5e1-129d2228ff23@github.com>

```
Victoria Dye <vdye@github.com> writes:

> 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.


```
