Thread (18 messages) 18 messages, 5 authors, 2024-06-13

Re: [PATCH] uapi/asm/termbits: Use the U integer suffix for bit fields

From: Alejandro Colomar <alx@kernel.org>
Date: 2024-06-12 15:08:00
Also in: linux-man

Hi Greg,

On Wed, Jun 12, 2024 at 04:21:25PM GMT, Greg KH wrote:
On Wed, Jun 12, 2024 at 04:00:18PM +0200, Alejandro Colomar wrote:
quoted
I expect that these specific values and the operations done on them
probably don't trigger UB, since the shifts are done by a controlled
amount, and there are justa few operations done on them.
These, for the most part, are NOT used as shifts.
Quoting the EXAMPLES section in the manual page:

	tio.c_cflag &= ~(CBAUD << IBSHIFT);

(And yeah, that shift is presumably controlled, so that it doesn't
overflow, which is why I mean these are presumably just fine.)
quoted
TL;DR: The kernel isn't broken, but improving this would allow users to
enable stricter warnings, which is a good thing.
Enable it where?
I meant in user space programs that use termbits stuff.  (That this may
also allow the kernel to eventually have stricter warnings, I don't
know.  It might help.  But mostly meant it for user space.)

So, if I have a user-space program (or more likely a library) which
wraps these ioctls, I'd prefer to be able to enable the warnings I
reported, to preclude any mistakes in my code.  That would need the
constants to be unsigned, to avoid false negatives.

Cheers,
Alex

-- 
<https://www.alejandro-colomar.es/>

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help