On 2/27/22 5:11 PM, Linus Torvalds wrote:
On Sun, Feb 27, 2022 at 3:04 PM Alex Elder <elder@xxxxxxxxxx> wrote:
Glancing at the Greybus code, I don't believe there's any
reason it needs to shift a negative value. Such warnings
could be fixed by making certain variables unsigned, for
example.
As mentioned in the original thread, making things unsigned actually
is likely to introduce bugs and make things worse.
Understood. What I meant is that the shifts were producing
single-bit masks from plain int values that range from 0 to 10
or something (in a for loop). Looking again though, that it's
not so simple. Regardless, your point about the warning is
good and I won't plan to "fix" this.
Thanks.
-Alex
The warning is simply bogus, and the fact that it was enabled by
-Wextra in gcc for std=gnu99 and up was a mistake that looks likely to
be fixed in gcc.
So don't try to "fix" the code to make any possible warnings go away.
You may just make things worse.
(That is often true in general for the more esoteric warnings, but in
this case it's just painfully more obvious).
Linus