From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Bart Van Assche <bvanassche@acm.org>,
Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
linux-block <linux-block@vger.kernel.org>,
Damien Le Moal <damien.lemoal@opensource.wdc.com>,
Naohiro Aota <naohiro.aota@wdc.com>,
Johannes Thumshirn <jth@kernel.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Steven Rostedt <rostedt@goodmis.org>,
Sparse Mailing-list <linux-sparse@vger.kernel.org>
Subject: Re: [PATCH 51/51] fs/zonefs: Fix sparse warnings in tracing code
Date: Sun, 26 Jun 2022 22:10:02 +0200 [thread overview]
Message-ID: <20220626201002.net2d4clpe23j24n@mail> (raw)
In-Reply-To: <CAHk-=whMV0CAb66pJASCcAwMZNfJpRKrO=EwXcm-vWUnXF7gDA@mail.gmail.com>
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@linux-foundation.org> 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
next prev parent reply other threads:[~2022-06-26 20:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220623180528.3595304-1-bvanassche@acm.org>
[not found] ` <20220623180528.3595304-52-bvanassche@acm.org>
[not found] ` <20220624045613.GA4505@lst.de>
[not found] ` <aa044f61-46f0-5f21-9b17-a1bb1ff9c471@acm.org>
[not found] ` <20220625092349.GA23530@lst.de>
[not found] ` <3eed7994-8de2-324d-c373-b6f4289a2734@acm.org>
2022-06-26 9:58 ` [PATCH 51/51] fs/zonefs: Fix sparse warnings in tracing code Luc Van Oostenryck
2022-06-26 15:42 ` Bart Van Assche
2022-06-26 16:24 ` Luc Van Oostenryck
2022-06-26 16:33 ` Linus Torvalds
2022-06-26 16:50 ` Linus Torvalds
2022-06-26 20:10 ` Luc Van Oostenryck [this message]
2022-06-26 19:44 ` Luc Van Oostenryck
2022-06-27 19:05 ` [PATCH 0/5] allow -1 and compares in bitwise types Luc Van Oostenryck
2022-06-27 19:05 ` [PATCH 1/5] bitwise: add testcases Luc Van Oostenryck
2022-06-27 19:05 ` [PATCH 2/5] bitwise: accept all ones as non-restricted value Luc Van Oostenryck
2022-06-27 23:32 ` Ramsay Jones
2022-06-27 19:05 ` [PATCH 3/5] bitwise: allow compares for bitwise types Luc Van Oostenryck
2022-06-27 19:20 ` Linus Torvalds
2022-06-27 23:34 ` Ramsay Jones
2022-06-27 19:05 ` [PATCH 4/5] bitwise: do not remove the signedness of " Luc Van Oostenryck
2022-06-27 19:05 ` [PATCH 5/5] bitwise: early expansion of simple constants Luc Van Oostenryck
2022-06-27 19:14 ` [PATCH 0/5] allow -1 and compares in bitwise types Linus Torvalds
2022-06-27 19:15 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220626201002.net2d4clpe23j24n@mail \
--to=luc.vanoostenryck@gmail.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=damien.lemoal@opensource.wdc.com \
--cc=hch@lst.de \
--cc=jth@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=naohiro.aota@wdc.com \
--cc=rostedt@goodmis.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).