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

Re: [PATCH v2] symlinks: use unsigned int for flags

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 21, 2026, 18:04 UTC
Message-ID
<xmqqzf66u9jj.fsf@gitster.g>
In-Reply-To
<20260121162640.424126-1-a3205153416@gmail.com>
Tian Yuchen <a3205153416@gmail.com> writes:
> The 'flags' and 'track_flags' fields in symlinks.c are used
> strictly as a collection of bits (using bitwise operators including
> &, |, ~). Using a signed integer for bitmasks may lead to undefined
> behavior with shift operations and logic errors if the MSB is touched.

Which we do not do, so the "signed can lead to bugs" is a valid concern and moving to unsigned is a good mitigation, but ...

>
> Change these fields from 'int' to 'unsigned int' to align with C
> standards and typical usage patterns.

... I'd tone it down a bit by replacing "aling with C standards and typical" with "match our", if I were writing this.

Show 11 quoted lines
>
> Signed-off-by: Tian Yuchen <a3205153416@gmail.com>
>
> ---
> Changes in v2:
>
> Decouple definition of 'ret' and 'saved_errno' from 'save_flags'.
> 'ret' captures the return value of lstat() which can be -1, so it
> must remain signed. Same applies to 'saved_errno'.
>
> (Thanks to Patrick Steinhardt for spotting this)
Yes, indeed.  Thanks.
Previous: Tian YuchenNext: Tian Yuchen
Message 2 of 3 in “symlinks: use unsigned int for flags”
  1. symlinks: use unsigned int for flagsTian Yuchen, Jan 21, 2026
  2. Junio C HamanoJan 21, 2026
  3. 1/1 symlinks: use unsigned int for flagsTian Yuchen, Feb 16, 2026

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.