All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>
Cc: Markus Armbruster <armbru@redhat.com>,
	Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] QAPI and empty structs
Date: Tue, 23 Dec 2014 08:54:25 -0700	[thread overview]
Message-ID: <54999031.8060302@redhat.com> (raw)
In-Reply-To: <CAFEAcA_CTdMNCP=p8_qegegy-K_Jop+CR7xU9-MOZSSJaWN3HQ@mail.gmail.com>

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

On 12/23/2014 08:50 AM, Peter Maydell wrote:
> In qapi-schema.json we have a couple of entries that define
> empty structures, like this:
> 
> { 'type': 'ChardevDummy', 'data': { } }
> 
> In the generated qapi-types.h these are turned into empty C structs:
> 

> Although you could argue that we don't care about differences
> in C and C++ semantics, having a zero-sized struct floating
> around seems a bit risky to me, since for instance a naive
> attempt to g_malloc() space for it will return NULL.

Oh, good point.

> 
> How should we handle these? Should the qapi-types generator
> stick a dummy field in so they aren't zero sized?

Sounds like the best plan to me.

> Are they
> actually an error in the schema? (what's the point of them?)

No, they are valid - it is how you express a union between a branch that
needs no additional members compared to any other branch.

> Do we claim that actually all our code correctly handles
> zero sized structs and just suppress the clang warning?

I'd be fine with adding a dummy member.

-- 
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:[~2014-12-23 15:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-23 15:50 [Qemu-devel] QAPI and empty structs Peter Maydell
2014-12-23 15:54 ` Eric Blake [this message]
2015-01-12 15:31   ` Markus Armbruster
2015-01-12 15:33     ` Peter Maydell

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=54999031.8060302@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=lcapitulino@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.