[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/8] qapi script: report error for default case
From: |
Eric Blake |
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 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 |
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 <address@hidden>
> ---
> 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
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH 0/8] qapi script: support enum as discriminator and better enum name, Wenchao Xia, 2013/11/06
- [Qemu-devel] [PATCH 4/8] qapi script: code move for generate_enum_name(), Wenchao Xia, 2013/11/06
- [Qemu-devel] [PATCH 5/8] qapi script: use same function to generate enum string, Wenchao Xia, 2013/11/06
- [Qemu-devel] [PATCH 1/8] qapi script: remember enum values, Wenchao Xia, 2013/11/06
- [Qemu-devel] [PATCH 6/8] qapi script: not generate hidden enum type for pre-defined enum discriminator, Wenchao Xia, 2013/11/06
- [Qemu-devel] [PATCH 3/8] qapi script: check correctness of discriminator values in union, Wenchao Xia, 2013/11/06
- [Qemu-devel] [PATCH 2/8] qapi script: report error for default case in union visit, Wenchao Xia, 2013/11/06
- Re: [Qemu-devel] [PATCH 2/8] qapi script: report error for default case in union visit,
Eric Blake <=
- [Qemu-devel] [PATCH 7/8] qapi script: do not add "_" for every capitalized char in enum, Wenchao Xia, 2013/11/06
- [Qemu-devel] [PATCH 8/8] tests: add cases for inherited struct and union with discriminator, Wenchao Xia, 2013/11/06