Re: [PATCH 51/51] fs/zonefs: Fix sparse warnings in tracing code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jun 26, 2022 at 09:50:50AM -0700, Linus Torvalds wrote:
> 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.

Well, this "there is no negative constants, only minus positive ones" 
is kinda special. Maybe we can special-case this, just doing an early
mini-expansion of PREOP('-', EXPR_VALUE). I'm not sure about all
implications it would have on typechecking though.

> 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"

Yes, I fully agree
Also, it's the only 'strong' type that sparse has (IIRC nocast was
too weak), so it's used for everything. Allowing only the bitwise
operators is often too restrictive. I think that often what people
just need is an unique type that doesn't mix with other types
but that can 1) mix with constants (certainly with 0, 1 and -1) and
2) can use the usual arithmetic operations (certainly the compares).

-- Luc



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux