qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] using fdt_setprop() to set properties to empty values
@ 2017-02-23 12:33 Peter Maydell
  2017-02-23 14:52 ` Eric Blake
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2017-02-23 12:33 UTC (permalink / raw)
  To: QEMU Developers, David Gibson

What's the right way to use libfdt's fdt_setprop to set a property
to have an empty value? At the moment in QEMU we tend to use
  fdt_setprop(fdt, nodeoffset, "propertyname", NULL, 0);

and git grep 'fdt_setprop.*NULL' produces examples of this usage in
PPC and ARM fdt creation code.

However the fdt_setprop() documentation doesn't document that a NULL
value pointer is OK if the length is 0, and indeed the implementation
unconditionally calls memcpy(prop->data, val, len), which is
undefined behaviour, and warned about by clang sanitizers if you
build libfdt with them:
 dtc/libfdt/fdt_rw.c:288:21: runtime error: null pointer passed
   as argument 2, which is declared to never be null

So what's the best thing to do here? I can't offhand think of a
non-ugly/non-confusing way to pass a valid pointer here...

thanks
-- PMM

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

end of thread, other threads:[~2017-03-03  6:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-23 12:33 [Qemu-devel] using fdt_setprop() to set properties to empty values Peter Maydell
2017-02-23 14:52 ` Eric Blake
2017-02-23 22:49   ` David Gibson
2017-02-24  0:16     ` David Gibson
2017-02-24 10:35       ` Peter Maydell
2017-02-27  1:05         ` David Gibson
2017-02-27 10:11           ` Peter Maydell
2017-03-01  0:16             ` David Gibson
2017-03-01  1:17               ` David Gibson
2017-03-03  6:30             ` David Gibson

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