|
|
Subscribe / Log in / New account

Re: [PATCH] kbuild: treat char as always signed

Thread information [Search the linux-kernel archive]

From:  Linus Torvalds <torvalds-AT-linux-foundation.org>
To:  Andy Shevchenko <andriy.shevchenko-AT-linux.intel.com>
Subject:  Re: [PATCH] kbuild: treat char as always signed
Date:  Wed, 19 Oct 2022 12:36:01 -0700
Message-ID:  <CAHk-=wgoH_rZiv84-53dGF5btC-1FPZc9nFJM=48NVAmR1p7Sw@mail.gmail.com>
Cc:  Nick Desaulniers <ndesaulniers-AT-google.com>, Segher Boessenkool <segher-AT-kernel.crashing.org>, "Jason A. Donenfeld" <Jason-AT-zx2c4.com>, linux-kernel-AT-vger.kernel.org, linux-kbuild-AT-vger.kernel.org, linux-arch-AT-vger.kernel.org, linux-toolchains-AT-vger.kernel.org, Masahiro Yamada <masahiroy-AT-kernel.org>, Kees Cook <keescook-AT-chromium.org>, Andrew Morton <akpm-AT-linux-foundation.org>, Greg Kroah-Hartman <gregkh-AT-linuxfoundation.org>

On Wed, Oct 19, 2022 at 12:23 PM Andy Shevchenko
<[email protected]> wrote:
>
> > We do have a couple of signed bitfields in the kernel, but they are
> > unusual enough that it's actually a good thing that sparse just made
> > people be explicit about it.
>
> At least drivers/media/usb/msi2500/msi2500.c:289 can be converted
> to use sign_extend32() I believe.

Heh. I didn't even look at that one - I did check that yeah, the MIPS
ones made sense (I say "ones", because while my grep pattern only
finds one, there are several others that have spacing that just made
my grep miss them).

You're right, that msi2500 use is a very odd use of bitfields for just
sign extension.

That's hilariously odd code, but not exactly wrong. And using "signed
int x:14" does make it very explicit that the bitfield wants that
sign.

And that code does actually have a fair number of comments to explain
each step, so I think it's all ok. Strange, but ok.

                  Linus


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds