qemu-devel
[Top][All Lists]
Advanced

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

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


From: Eric Blake
Subject: Re: [Qemu-devel] using fdt_setprop() to set properties to empty values
Date: Thu, 23 Feb 2017 08:52:01 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0

On 02/23/2017 06:33 AM, Peter Maydell wrote:
> 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...

Does fdt_setprop(fdt, nodeoffset, "propertyname", "", 0) do the right thing?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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