qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] using fdt_setprop() to set properties to empty values


From: Peter Maydell
Subject: [Qemu-devel] using fdt_setprop() to set properties to empty values
Date: Thu, 23 Feb 2017 12:33:31 +0000

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]