]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qapi: Report invalid '*' prefix like any other invalid name
authorMarkus Armbruster <armbru@redhat.com>
Fri, 27 Sep 2019 13:46:24 +0000 (15:46 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Sat, 28 Sep 2019 15:17:19 +0000 (17:17 +0200)
The special "does not allow optional name" error is well meant, but
confusing in practice.  Drop it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190927134639.4284-12-armbru@redhat.com>

scripts/qapi/common.py
tests/qapi-schema/bad-ident.err
tests/qapi-schema/flat-union-discriminator-bad-name.err
tests/qapi-schema/flat-union-discriminator-bad-name.json
tests/qapi-schema/union-optional-branch.err

index d0d997f31c57f2f1b3663e5b3df59f47b988cfe9..a4cf41f13e90f1737e15b1b2d73b02e41fd03f66 100644 (file)
@@ -724,11 +724,8 @@ def check_name_str(name, info, source,
     global valid_name
     membername = name
 
-    if name.startswith('*'):
+    if allow_optional and name.startswith('*'):
         membername = name[1:]
-        if not allow_optional:
-            raise QAPISemError(info, "%s does not allow optional name '%s'"
-                               % (source, name))
     # Enum members can start with a digit, because the generated C
     # code always prefixes it with the enum name
     if enum_member and membername[0].isdigit():
@@ -741,6 +738,7 @@ def check_name_str(name, info, source,
     if not permit_upper and name.lower() != name:
         raise QAPISemError(
             info, "%s uses uppercase in name '%s'" % (source, name))
+    assert not membername.startswith('*')
 
 
 def add_name(name, info, meta):
index 687888985478943e2c8456dbee985564c78bd1fa..ddc96bd3a901f1f848586c1c64e001a8fe8a4e94 100644 (file)
@@ -1,2 +1,2 @@
 tests/qapi-schema/bad-ident.json: In struct '*oops':
-tests/qapi-schema/bad-ident.json:2: 'struct' does not allow optional name '*oops'
+tests/qapi-schema/bad-ident.json:2: 'struct' uses invalid name '*oops'
index f7f64c5c1a775898c14ae4e4d4ebeff10ba3d368..44e41883b11024e80a31f00bc7a49cbd45e13a30 100644 (file)
@@ -1,2 +1,2 @@
 tests/qapi-schema/flat-union-discriminator-bad-name.json: In union 'MyUnion':
-tests/qapi-schema/flat-union-discriminator-bad-name.json:7: discriminator of flat union 'MyUnion' does not allow optional name '*switch'
+tests/qapi-schema/flat-union-discriminator-bad-name.json:7: discriminator of flat union 'MyUnion' uses invalid name '*switch'
index 66376084fce9d31a02bb562ed34b869c46d90718..ea84b75cac821bb8e4d02c35edd5d1b75c3dba2b 100644 (file)
@@ -1,5 +1,5 @@
 # discriminator '*switch' isn't a member of base, 'switch' is
-# reports "does not allow optional name", which is good enough
+# reports "uses invalid name", which is good enough
 { 'enum': 'Enum', 'data': [ 'one', 'two' ] }
 { 'struct': 'Base',
   'data': { '*switch': 'Enum' } }
index a5677f74bca74ea900c425e3e6533ba5fe96184a..8e9b18d7c6e360fd0408bb66636764e553b40c54 100644 (file)
@@ -1,2 +1,2 @@
 tests/qapi-schema/union-optional-branch.json: In union 'Union':
-tests/qapi-schema/union-optional-branch.json:2: member of union 'Union' does not allow optional name '*a'
+tests/qapi-schema/union-optional-branch.json:2: member of union 'Union' uses invalid name '*a'