public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Tian Yuchen <a3205153416@gmail.com>
Cc: git@vger.kernel.org,  ps@pks.im
Subject: Re: [PATCH v2] symlinks: use unsigned int for flags
Date: Wed, 21 Jan 2026 10:04:32 -0800	[thread overview]
Message-ID: <xmqqzf66u9jj.fsf@gitster.g> (raw)
In-Reply-To: <20260121162640.424126-1-a3205153416@gmail.com> (Tian Yuchen's message of "Thu, 22 Jan 2026 00:26:40 +0800")

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.

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

  reply	other threads:[~2026-01-21 18:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-21 16:26 [PATCH v2] symlinks: use unsigned int for flags Tian Yuchen
2026-01-21 18:04 ` Junio C Hamano [this message]
2026-02-16 17:20   ` [PATCH v3 1/1] " Tian Yuchen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqzf66u9jj.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=a3205153416@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox