From: Junio C Hamano Date: Wed, 21 Jan 2026 18:04:32 GMT Subject: Re: [PATCH v2] symlinks: use unsigned int for flags Message-ID: In-Reply-To: <20260121162640.424126-1-a3205153416@gmail.com> Tian Yuchen 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 > > --- > 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.