linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Alejandro Colomar <alx@kernel.org>
Cc: linux-api@vger.kernel.org, linux-man@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Palmer Dabbelt <palmer@rivosinc.com>,
	libc-alpha@sourceware.org
Subject: Re: [PATCH] uapi/asm/termbits: Use the U integer suffix for bit fields
Date: Wed, 12 Jun 2024 15:35:20 +0200	[thread overview]
Message-ID: <2024061214-absolute-deranged-14bf@gregkh> (raw)
In-Reply-To: <20240612131633.449937-2-alx@kernel.org>

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@linuxfoundation.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Palmer Dabbelt <palmer@rivosinc.com>
> Cc: <linux-api@vger.kernel.org>
> Cc: <libc-alpha@sourceware.org>
> Signed-off-by: Alejandro Colomar <alx@kernel.org>
> ---
> 
> 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

  reply	other threads:[~2024-06-12 13:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12 12:16 termios constants should be unsigned Alejandro Colomar
2024-06-12 12:22 ` Greg KH
2024-06-12 13:16   ` [PATCH] uapi/asm/termbits: Use the U integer suffix for bit fields Alejandro Colomar
2024-06-12 13:35     ` Greg KH [this message]
2024-06-12 14:00       ` Alejandro Colomar
2024-06-12 14:21         ` Greg KH
2024-06-12 15:07           ` Alejandro Colomar
2024-06-12 14:55 ` termios constants should be unsigned Paul Eggert
2024-06-12 16:28   ` Alejandro Colomar
2024-06-12 17:47     ` enh
2024-06-12 18:55       ` Alejandro Colomar
2024-06-12 19:01       ` Alejandro Colomar
2024-06-12 21:54         ` enh
2024-06-12 22:22           ` Alejandro Colomar
2024-06-12 18:27     ` Paul Eggert
2024-06-13 12:32   ` Zack Weinberg
2024-06-13 21:12     ` Paul Eggert
2024-06-13 21:37       ` Alejandro Colomar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2024061214-absolute-deranged-14bf@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=alx@kernel.org \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-man@vger.kernel.org \
    --cc=palmer@rivosinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).