From: David Laight <David.Laight@ACULAB.COM>
To: 'Sven Eckelmann' <sven@narfation.org>, Arnd Bergmann <arnd@arndb.de>
Cc: "b.a.t.m.a.n@lists.open-mesh.org"
<b.a.t.m.a.n@lists.open-mesh.org>,
"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] asm-generic: avoid sparse {get,put}_unaligned warning
Date: Tue, 27 Jul 2021 08:44:21 +0000 [thread overview]
Message-ID: <bb831fbad4f74e11b868d936f7616d1a@AcuMS.aculab.com> (raw)
In-Reply-To: <20210724162429.394792-1-sven@narfation.org>
From: Sven Eckelmann
> Sent: 24 July 2021 17:24
>
> Sparse will try to check casting of simple integer types which are marked
> as __bitwise. This for example "disallows" simple casting of __be{16,32,64}
> or __le{16,32,64} to other types. This is also true for pointers to
> variables with this type.
>
> But the new generic {get,put}_unaligned is doing that by (reinterpret)
> casting the original pointer to a new (anonymous) struct pointer. This will
> then create warnings like:
>
> net/batman-adv/distributed-arp-table.c:1461:19: warning: cast from restricted __be32 *
> net/batman-adv/distributed-arp-table.c:1510:23: warning: cast from restricted __be32 [usertype]
> *[assigned] magic
> net/batman-adv/distributed-arp-table.c:1588:24: warning: cast from restricted __be32 [usertype]
> *[assigned] yiaddr
>
> The special attribute force must be used in such statements when the cast
> is known to be safe to avoid these warnings.
At least the __force is being added to an existing cast.
The real problems are when a (__force __le32)value cast is used
to silence sparse.
These should really be something like:
__tell_sparce(__le32, value)
so that the whole thing can be removed by the preprocessor when
compiling the code.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
prev parent reply other threads:[~2021-07-27 8:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-24 16:24 [PATCH] asm-generic: avoid sparse {get,put}_unaligned warning Sven Eckelmann
2021-07-24 17:01 ` Al Viro
2021-07-26 12:57 ` Arnd Bergmann
2021-07-26 15:04 ` Sven Eckelmann
2021-07-26 16:22 ` Arnd Bergmann
2021-07-27 8:44 ` David Laight [this message]
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=bb831fbad4f74e11b868d936f7616d1a@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=arnd@arndb.de \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sven@narfation.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).