On Sun, Jun 26, 2022 at 9:33 AM Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote: > > (a) for the casting part, I actually suspect we should drop the > warning about castign integers to restricted types. Heh. Trying that out, I find we seem to do this at the wrong point anyway. I removed the check for "value of 0 is ok", and it continues to warn about casting "-1". Because it does that before "-1" has even been simplified, so it actually sees it as an *expression* ("negate the constant 1") rather than as the *value* -1, and it warns. That's a bit sad since really -1 and ~0 really both should be ok for the same reason plain zero is ok - regardless of the whole "do we just allow it for constants in general" thing. I think the bitwise thing was always a bit half-baked. It was designed for detecting little-endian and big-endian issues, and "bitmask" types. And it's wonderful for the basics of that, but I think it was never really thought through for this kind of extended use where we end up having generic macros that do still make sense for them, but aren't that exact "avoid assigning bitwise values to other values" Linus