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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 12, 2024 at 03:16:58PM +0200, Alejandro Colomar wrote:
> Constants that are to be used in bitwise operations should be unsigned,
> or a user could easily trigger Undefined Behavior.

Wait, do we really have such broken compilers out there?  If so, how has
no one hit this before?

> Also, the types where these constants are to be assigned are unsigned,
> so this makes it more consistent.

Fair enough.

> alx@debian:/usr/include$ grepc -tt termios asm-generic/
> asm-generic/termbits.h:struct termios {
> 	tcflag_t c_iflag;		/* input mode flags */
> 	tcflag_t c_oflag;		/* output mode flags */
> 	tcflag_t c_cflag;		/* control mode flags */
> 	tcflag_t c_lflag;		/* local mode flags */
> 	cc_t c_line;			/* line discipline */
> 	cc_t c_cc[NCCS];		/* control characters */
> };
> alx@debian:/usr/include$ grepc -tt tcflag_t asm-generic/
> asm-generic/termbits.h:typedef unsigned int	tcflag_t;
> alx@debian:/usr/include$ grepc -tt cc_t asm-generic/
> asm-generic/termbits-common.h:typedef unsigned char	cc_t;
> alx@debian:/usr/include$ grepc -tt speed_t asm-generic/
> asm-generic/termbits-common.h:typedef unsigned int	speed_t;
> 
> Link: <https://lore.kernel.org/linux-api/2024061222-scuttle-expanse-6438@gregkh/T/>
> Cc: Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: Palmer Dabbelt <palmer@xxxxxxxxxxxx>
> Cc: <linux-api@xxxxxxxxxxxxxxx>
> Cc: <libc-alpha@xxxxxxxxxxxxxx>
> Signed-off-by: Alejandro Colomar <alx@xxxxxxxxxx>
> ---
> 
> Hi Greg,
> 
> On Wed, Jun 12, 2024 at 02:22:37PM GMT, Greg KH wrote:
> > Have a proposed patch that you feel would resolve this?
> >
> > thanks,
> >
> > greg k-h
> 
> Here it is.  :)
> 
> For reviewing it, I suggest using '--word-diff-regex=.'.
> 
> I compiled the kernel, and it seems ok; didn't test more than that.

With this change, can the glibc versions then be dropped to just rely on
these instead?

thanks,

greg k-h




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux