From: Christoph Hellwig <hch@infradead.org>
To: linux-sparse@vger.kernel.org
Cc: linux-xfs@vger.kernel.org
Subject: sparse feature request: nocast integer types
Date: Wed, 8 Nov 2023 21:03:34 -0800 [thread overview]
Message-ID: <ZUxoJh7NlWw+uBlt@infradead.org> (raw)
Hi dear spearse developers,
in a lot of kernel code we have integer types that store offsets and
length in certain units (typically 512 byte disk "sectors", file systems
block sizes, and some weird variations of the same), and we had a fair
amount of bugs beause people get confused about which ones to use.
I wonder if it is possible to add an attribute (say nocast) that works
similar to __attribute__((bitwise)) in that it disallows mixing this
type with other integer types, but unlike __attribute__((bitwise))
allows all the normal arithmetics on it? That way we could annotate
all the normal conversion helpers with __force overrides and check
where people are otherwise mixing these types.
next reply other threads:[~2023-11-09 5:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-09 5:03 Christoph Hellwig [this message]
[not found] ` <CAMHZB6G_TZJ_uQGm5an0-bhG8wCxpEQrUCShen7O61Q9arAf+Q@mail.gmail.com>
2023-11-09 5:30 ` sparse feature request: nocast integer types Christoph Hellwig
[not found] ` <CAMHZB6H7Y0m2Y-ZD0PMKiGDeo7_sy=scDrzbBbBuUJfuzLK-Lg@mail.gmail.com>
2023-11-09 5:44 ` Christoph Hellwig
2023-11-09 17:57 ` Linus Torvalds
2023-11-27 12:51 ` Dan Carpenter
2023-11-27 16:05 ` Christoph Hellwig
2023-11-27 17:26 ` Linus Torvalds
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=ZUxoJh7NlWw+uBlt@infradead.org \
--to=hch@infradead.org \
--cc=linux-sparse@vger.kernel.org \
--cc=linux-xfs@vger.kernel.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 read-only IMAP folder(s) and NNTP newsgroup(s).