Tian Yuchen [off-list ref] 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 <redacted>
---
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.