linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* detecting misuse of of_get_property
@ 2019-10-28 19:32 Rasmus Villemoes
  2019-10-28 22:49 ` Luc Van Oostenryck
  2019-10-29 10:50 ` Dan Carpenter
  0 siblings, 2 replies; 9+ messages in thread
From: Rasmus Villemoes @ 2019-10-28 19:32 UTC (permalink / raw)
  To: Luc Van Oostenryck, Dan Carpenter; +Cc: linux-sparse, LKML

Hi,

I just spent some time trying to convert some so far PPC-only drivers to
be more generic. One of the things I had to do was convert stuff like

  u32 *val = of_get_property(np, "bla", NULL);
  do_stuff_with(*val);

with

  of_property_read_u32(np, "bla", &val);
  do_stuff_with(val);

(error checking omitted for simplicity). The problem is that
of_get_property() just returns void*. When the property is just a
string, there's no problem interpreting that as a char*. But when the
property is a number of array of numbers, I'd like some way to flag
casting it to u32* as an error - if you cast it to a (pointer to integer
type wider than char), it must be to a __be32*. Is there some way
sparse/smatch could help find such cases?

Rasmus

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-10-29 13:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-28 19:32 detecting misuse of of_get_property Rasmus Villemoes
2019-10-28 22:49 ` Luc Van Oostenryck
2019-10-29  7:24   ` Rasmus Villemoes
2019-10-29 10:50 ` Dan Carpenter
2019-10-29 11:43   ` Rasmus Villemoes
2019-10-29 12:57     ` Dan Carpenter
2019-10-29 11:47   ` Luc Van Oostenryck
2019-10-29 12:55     ` Dan Carpenter
2019-10-29 13:37       ` Luc Van Oostenryck

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).