From: Eric Blake <eblake@redhat.com>
To: Wenchao Xia <xiawenc@linux.vnet.ibm.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, armbru@redhat.com, mdroth@linux.vnet.ibm.com,
lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH 2/8] qapi script: report error for default case in union visit
Date: Tue, 12 Nov 2013 09:51:01 -0700 [thread overview]
Message-ID: <52825C75.3050505@redhat.com> (raw)
In-Reply-To: <1383766420-20745-3-git-send-email-xiawenc@linux.vnet.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1320 bytes --]
On 11/06/2013 12:33 PM, Wenchao Xia wrote:
> It is possible to reach default case, when an union have a enum
> discriminator, so don't abort() but report the error message.
>
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
> scripts/qapi-visit.py | 14 ++++++++++++--
> 1 files changed, 12 insertions(+), 2 deletions(-)
I still think this is not ideal. You are proposing a runtime error:
> + # Tell caller the value is invalid, since the discriminator value maybe an
> + # unmapped enum value.
> ret += mcgen('''
> default:
> - abort();
> + error_setg(&err,
> + "Invalid discriminator value %(pi)s for %(name)s",
> + (*obj)->kind);
> + break;
> }
whereas I'm requesting a compile-time error - it is much easier for
maintenance reasons to have the generator require up-front that all enum
values are covered, and loudly complain if an enum type is extended
without also extending the use of that enum type in a union, than it is
to silently generate a runtime error and wait for the bug reports
several weeks down the road.
--
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: 621 bytes --]
next prev parent reply other threads:[~2013-11-12 16:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-06 19:33 [Qemu-devel] [PATCH 0/8] qapi script: support enum as discriminator and better enum name Wenchao Xia
2013-11-06 19:33 ` [Qemu-devel] [PATCH 1/8] qapi script: remember enum values Wenchao Xia
2013-11-06 19:33 ` [Qemu-devel] [PATCH 2/8] qapi script: report error for default case in union visit Wenchao Xia
2013-11-12 16:51 ` Eric Blake [this message]
2013-11-06 19:33 ` [Qemu-devel] [PATCH 3/8] qapi script: check correctness of discriminator values in union Wenchao Xia
2013-11-12 18:12 ` Eric Blake
2013-11-13 2:30 ` Wenchao Xia
2013-11-06 19:33 ` [Qemu-devel] [PATCH 4/8] qapi script: code move for generate_enum_name() Wenchao Xia
2013-11-12 18:13 ` Eric Blake
2013-11-06 19:33 ` [Qemu-devel] [PATCH 5/8] qapi script: use same function to generate enum string Wenchao Xia
2013-11-06 19:33 ` [Qemu-devel] [PATCH 6/8] qapi script: not generate hidden enum type for pre-defined enum discriminator Wenchao Xia
2013-11-06 19:33 ` [Qemu-devel] [PATCH 7/8] qapi script: do not add "_" for every capitalized char in enum Wenchao Xia
2013-11-06 19:33 ` [Qemu-devel] [PATCH 8/8] tests: add cases for inherited struct and union with discriminator Wenchao Xia
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=52825C75.3050505@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=xiawenc@linux.vnet.ibm.com \
/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.