qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [Qemu-devel] using fdt_setprop() to set properties to empty values
Date: Thu, 23 Feb 2017 08:52:01 -0600	[thread overview]
Message-ID: <448f3a5f-044e-bcac-60bd-2ce074021be9@redhat.com> (raw)
In-Reply-To: <CAFEAcA8AZup28Sho8hLeCRVf4iSdLdeFHvz1h4-X7FwVBcANyg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1104 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2017-02-23 14:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=448f3a5f-044e-bcac-60bd-2ce074021be9@redhat.com \
    --to=eblake@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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).