qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH RFC 03/10] qapi script: check correctness of dis


From: Wenchao Xia
Subject: Re: [Qemu-devel] [PATCH RFC 03/10] qapi script: check correctness of discriminator values in union
Date: Wed, 06 Nov 2013 11:02:38 +0800
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0.1

于 2013/11/5 21:25, Eric Blake 写道:
On 11/04/2013 05:37 PM, Wenchao Xia wrote:
It will check whether the values specfied are wrotten correctly when

s/specfied/specified/
s/wrotten/written/

discriminator is a pre-defined enum type, which help check whether the
schema is in good form.

It is allowed that, not every value in enum is used, so do not check

s/that,/that/

that case.

Why do you allow partial coverage?  That feels like an accident waiting
to happen.  Does the user get a sane error message if they request an
enum value that wasn't mapped to a union branch?  I think it would be
wiser to mandate that if the discriminator is an enum, then the union
must cover all values of the enum.

  abort() will be called in qapi-visit.c, it is OK for output visitor,
but bad for input visitor since user input may trigger it. I think
change abort() to error_set() could solve the problem, then we allow
map part of enum value.

+
+# Return the descriminator enum define, if discriminator is specified in

s/descriminator/discriminator/

+# @expr and it is a pre-defined enum type
+def descriminator_find_enum_define(expr):

s/descriminator/discriminator/ - and fix all callers

+    discriminator = expr.get('discriminator')
+    base = expr.get('base')
+
+    # Only support discriminator when base present
+    if not (discriminator and base):
+        return None
+
+    base_fields = find_base_fields(base)
+
+    if not base_fields:
+        sys.stderr.write("Base '%s' is not a valid type\n"
+                         % base)
+        sys.exit(1)
+
+    descriminator_type = base_fields.get(discriminator)

s/descriminator/discriminator/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]