Re: termios constants should be unsigned
From: enh <hidden>
Date: 2024-06-12 17:47:16
Also in:
linux-man
On Wed, Jun 12, 2024 at 12:29 PM Alejandro Colomar [off-list ref] wrote:
Hi Paul, On Wed, Jun 12, 2024 at 07:55:14AM GMT, Paul Eggert wrote:quoted
On 2024-06-12 05:16, Alejandro Colomar wrote:quoted
tcgets.c:53:24: error: implicit conversion changes signedness: 'int' to 'tcflag_t' (aka 'unsigned int') [clang-diagnostic-sign-conversion,-warnings-as-errors]This is a bug in Clang not glibc, and if you're worried about it I suggest sending a bug report to the Clang folks about the false positive. Even GCC's -Wsign-conversion, which is at least smart enough to not warn about benign conversions like that, is too often so chatty that it's best avoided. A lot of this stuff is pedanticism that dates back to the bad old days when the C standard allowed ones' complement and signed magnitude representations of signed integers. Although it can be amusing to worry about that possibility (I know I've done it) it's never been a practical worry, and even the motivation of pedanticism is going away now that C23 requires two's complement.I know; I think I have -Weverything enabled in that run, which is known for its pedanticity. I usually disable it when it triggers a warning, since they are usually nonsense. But in this case, adding U is a net improvement, without downsides (or I can't see them).
well, any change like this is a potential source incompatibility ... i hacked these changes into AOSP, and it did break one bit of existing code that was already working around the sign differences --- this warning was enabled but the code had a cast to make the _other_ side of the comparison signed (rather than make this side of the comparison unsigned). Android's libc [bionic] uses the uapi headers directly, so we would be affected, but to be clear --- i'm fine with this if the consensus is to go this way. (but, yeah, i'm with the "how about we fix the language and compiler rather than all the extant code?" sentiment from Paul Eggert.)
So, while the kernel and glibc are just fine with this implicit conversion, they would be equally fine and even better without the conversion. Not a bug, but rather a slight improvement. Have a lovely day! Alex -- <https://www.alejandro-colomar.es/>