git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] diff-no-index: do not reference .d_type member of struct dirent

From
Collin Funk <collin.funk1@gmail.com>
Date
Jun 18, 2025, 20:37 UTC
Message-ID
<874iwcss4p.fsf@gmail.com>
In-Reply-To
<xmqqh60ces03.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 22 quoted lines
> Some platforms like AIX lack .d_type member in "struct dirent"; use
> the DTYPE(e) macro instead of a direct reference to e->d_type and
> when it yields DT_UNKNOWN, find the real type with get_dtype().
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  * get_dtype() was designed for a typical
>
>     - prepare the path in a strbuf B
>     - opendir(B)
>     - loop over readdir(B)
>       - do things to path (B + e->d_name)
>
>    code structure, but because this code path does not use a strbuf
>    (instead the path given to opendir is a "const char *"), the
>    entire thing becomes messier than necessary.  get_dtype() has a
>    short-cut to avoid having to concatenate path+e->d_name and run
>    (l)stat() when e->d_type exists and known, but we need to open
>    code it here.
>
>  diff-no-index.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)

Tested on AIX 7.3 like the previous patch just to be safe and it works as expected.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
Tested-by: Collin Funk <collin.funk1@gmail.com>

Thanks, Collin

Previous: Junio C Hamano
Message 2 of 2 in “diff-no-index: do not reference .d_type member of struct dirent”
  1. diff-no-index: do not reference .d_type member of struct direntJunio C Hamano, Jun 18, 2025
  2. Collin FunkJun 18, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.