[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VdUf8=y+y4Q3OtWc7owxg0uX8LhZY4Nrgnezuv+aSyzUg@mail.gmail.com>
Date: Wed, 3 Jun 2020 11:49:37 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Rikard Falkeborn <rikard.falkeborn@...il.com>
Cc: Emil Velikov <emil.l.velikov@...il.com>,
Syed Nayyar Waris <syednwaris@...il.com>,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
Kees Cook <keescook@...omium.org>,
Linus Walleij <linus.walleij@...aro.org>,
Andrew Morton <akpm@...ux-foundation.org>,
William Breathitt Gray <vilhelm.gray@...il.com>,
Arnd Bergmann <arnd@...db.de>,
Linux-Arch <linux-arch@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v7 1/4] bitops: Introduce the the for_each_set_clump macro
On Tue, Jun 2, 2020 at 10:01 PM Rikard Falkeborn
<rikard.falkeborn@...il.com> wrote:
> On Mon, Jun 01, 2020 at 11:33:30AM +0300, Andy Shevchenko wrote:
> > On Mon, Jun 01, 2020 at 12:37:16AM +0200, Rikard Falkeborn wrote:
> > > On Sun, May 31, 2020 at 02:00:45PM +0300, Andy Shevchenko wrote:
...
> > > If we cast to int, we don't need to worry about the signedness. If
> > > someone enters a value that can't be cast to int, there will still
> > > be a compiler warning about shift out of range.
> >
> > If the argument unsigned long long will it be the warning (it should not)?
>
> No, there should be no warning there.
>
> The inputs to GENMASK() needs to be between 0 and 31 (or 63 depending on the
> size of unsigned long). For any other values, there will be undefined behaviour,
> since the operands to the shifts in __GENMASK will be too large (or negative).
What I'm implying here that argument may be not constant, and compiler
can't know their values at hand.
So, in the following snippet
foo(unsigned long long x)
{
u32 y;
y = GENMASK(x, 0);
}
when you cast x to int wouldn't be a warning of possible value
reduction (even if we know that it won't be higher than 63/31)?
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists