Enum members should use '-', not '_'.  Enforce this.  Fix the fixable
offenders (all in tests/), and add the remainder to pragma
member-name-exceptions.

Signed-off-by: Markus Armbruster <arm...@redhat.com>
Message-Id: <20210323094025.3569441-28-arm...@redhat.com>
Reviewed-by: Eric Blake <ebl...@redhat.com>
---
 qapi/pragma.json                         | 8 ++++++++
 scripts/qapi/expr.py                     | 5 +++--
 tests/qapi-schema/enum-clash-member.err  | 2 +-
 tests/qapi-schema/enum-clash-member.json | 1 +
 4 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/qapi/pragma.json b/qapi/pragma.json
index f422a1a2ac..b4e17167e1 100644
--- a/qapi/pragma.json
+++ b/qapi/pragma.json
@@ -32,12 +32,15 @@
     'member-name-exceptions': [     # visible in:
         'ACPISlotType',             # query-acpi-ospm-status
         'AcpiTableOptions',         # -acpitable
+        'BlkdebugEvent',            # blockdev-add, -blockdev
         'BlkdebugSetStateOptions',  # blockdev-add, -blockdev
         'BlockDeviceInfo',          # query-block
         'BlockDeviceStats',         # query-blockstats
         'BlockDeviceTimedStats',    # query-blockstats
         'BlockIOThrottle',          # block_set_io_throttle
         'BlockInfo',                # query-block
+        'BlockdevAioOptions',       # blockdev-add, -blockdev
+        'BlockdevDriver',           # blockdev-add, query-blockstats, ...
         'BlockdevVmdkAdapterType',  # blockdev-create (to match VMDK spec)
         'BlockdevVmdkSubformat',    # blockdev-create (to match VMDK spec)
         'ColoCompareProperties',    # object_add, -object
@@ -46,10 +49,15 @@
         'FilterRewriterProperties', # object_add, -object
         'InputLinuxProperties',     # object_add, -object
         'NetdevTapOptions',         # netdev_add, query-netdev, -netdev
+        'ObjectType',               # object-add, -object
+        'PCIELinkSpeed',            # internal only
         'PciBusInfo',               # query-pci
         'PciDeviceInfo',            # query-pci
         'PciMemoryRegion',          # query-pci
+        'QKeyCode',                 # send-key, input-sent-event
         'QapiErrorClass',           # QMP error replies
+        'SshHostKeyCheckMode',      # blockdev-add, -blockdev
+        'SysEmuTarget',             # query-cpu-fast, query-target
         'UuidInfo',                 # query-uuid
         'VncClientInfo',            # query-vnc, query-vnc-servers, ...
         'X86CPURegister32'          # qom-get of x86 CPU properties
diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py
index ba9f7ad350..d968609c48 100644
--- a/scripts/qapi/expr.py
+++ b/scripts/qapi/expr.py
@@ -229,7 +229,7 @@ def check_enum(expr, info):
     if prefix is not None and not isinstance(prefix, str):
         raise QAPISemError(info, "'prefix' must be a string")
 
-    permit_upper = name in info.pragma.member_name_exceptions
+    permissive = name in info.pragma.member_name_exceptions
 
     members[:] = [m if isinstance(m, dict) else {'name': m}
                   for m in members]
@@ -243,7 +243,8 @@ def check_enum(expr, info):
         if member_name[0].isdigit():
             member_name = 'd' + member_name # Hack: hide the digit
         check_name_lower(member_name, info, source,
-                         permit_upper, permit_underscore=True)
+                         permit_upper=permissive,
+                         permit_underscore=permissive)
         check_if(member, info, source)
 
 
diff --git a/tests/qapi-schema/enum-clash-member.err 
b/tests/qapi-schema/enum-clash-member.err
index 5986571427..e4eb102ae2 100644
--- a/tests/qapi-schema/enum-clash-member.err
+++ b/tests/qapi-schema/enum-clash-member.err
@@ -1,2 +1,2 @@
 enum-clash-member.json: In enum 'MyEnum':
-enum-clash-member.json:2: value 'one_two' collides with value 'one-two'
+enum-clash-member.json:3: value 'one_two' collides with value 'one-two'
diff --git a/tests/qapi-schema/enum-clash-member.json 
b/tests/qapi-schema/enum-clash-member.json
index b6928b8bfd..82bcbf724b 100644
--- a/tests/qapi-schema/enum-clash-member.json
+++ b/tests/qapi-schema/enum-clash-member.json
@@ -1,2 +1,3 @@
 # we reject enums where members will clash when mapped to C enum
+{ 'pragma': { 'member-name-exceptions': [ 'MyEnum' ] } }
 { 'enum': 'MyEnum', 'data': [ 'one-two', 'one_two' ] }
-- 
2.26.3


Reply via email to