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 16:21:25 +0200 [thread overview]
Message-ID: <2024061223-saddlebag-gallantly-c35f@gregkh> (raw)
In-Reply-To: <tkfp53faunf5jlszu5k6jwwxgsl72faffiux7c3pykmnowapy6@wap3bvtvoebi>
On Wed, Jun 12, 2024 at 04:00:18PM +0200, Alejandro Colomar wrote:
> Hi Greg,
>
> On Wed, Jun 12, 2024 at 03:35:20PM GMT, Greg KH wrote:
> > 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?
>
> I meant this as a generic statement that signed integers on bitwise ops
> are bad, not as a specific statement that these values would trigger UB.
>
> 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.
> For example, a left shift where a set bit overflows the type (e.g.,
> 1<<32), causes UB.
Sure, but that's not in play here.
> The reason why it's better to avoid this at all even if we know these
> values work fine, is that programs using <asm/termbits.h> would need to
> disable those compiler warnings, which could silence warnings on other
> code which might be broken.
But again, you aren't using these as bit shifts, they are bit masks, or
values, only.
> 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?
thanks,
greg k-h
next prev parent reply other threads:[~2024-06-12 14:21 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
2024-06-12 14:00 ` Alejandro Colomar
2024-06-12 14:21 ` Greg KH [this message]
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=2024061223-saddlebag-gallantly-c35f@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.