2 ms·
It wasn't really anything to do with the language, and far more to do with the operating system kernel API. The fchown() system call supports passing -1, cast
by JdeBP 10y ago
It wasn't really anything to do with the language, and far more to do with the operating system kernel API.
The fchown() system call supports passing -1, cast to the appropriate type, as a no-op value. The systemd people were attempting to wrap similar semantics around fchmod(). Originally in 2014 M. Sievers specified (mode_t)0 as the no-op value, which wasn't a good choice, with M. Poettering changing it to (mode_t)-1 in 2015 but overlooking one place where the value remained tested against 0.
* https://github.com/systemd/systemd/commit/c38dfac9ed6c1c3beb3dd88ebf82a13d1e561ff8#diff-17b65efc8e12341f488ffdf9b5f52840R3388 https://github.com/systemd/systemd/commit/c38dfac9ed6c1c3beb...
- JdeBP 10y agoIncidentally: M. Sievers' original choice of (mode_t)0 as a no-op value lives on to this day in systemd-udevd. * https://github.com/systemd/systemd/blob/v232/src/udev/udev-rules.c#L2527 https://github.com/systemd/systemd/blob/v232/src/udev/udev-r...