From: David Gibson <david@gibson.dropbear.id.au>
To: Eric Blake <eblake@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] using fdt_setprop() to set properties to empty values
Date: Fri, 24 Feb 2017 09:49:11 +1100 [thread overview]
Message-ID: <20170223224911.GC17615@umbus.fritz.box> (raw)
In-Reply-To: <448f3a5f-044e-bcac-60bd-2ce074021be9@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1471 bytes --]
On Thu, Feb 23, 2017 at 08:52:01AM -0600, Eric Blake wrote:
> 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);
That's what I've always used..
> > 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
..but indeed that isn't really technically right.
> > 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?
That should work, but it's a bit clunky.
I guess I should add an fdt_setprop_empty() to libfdt.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2017-02-23 23:23 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
2017-02-23 22:49 ` David Gibson [this message]
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=20170223224911.GC17615@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=eblake@redhat.com \
--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).