Skip to contentSkip to conversation

QAPI patches patches for 2021-07-15

GIT PULL Applied Markus Armbruster 2 participants 3 messages Jul 15, 2021 – Jul 16, 2021

lore
Share & tools
lore
#0 lore raw

The following changes since commit a9649a719a44894b81f38dc1c5c1888ee684acef:

Merge remote-tracking branch 'remotes/cleber-gitlab/tags/python-next-pull-request' into staging (2021-07-14 18:09:09 +0100)

are available in the Git repository at:

git://repo.or.cz/qemu/armbru.git tags/pull-qapi-2021-07-15

for you to fetch changes up to a0c7b99bf75d85b616fa219a7d866fc72970f327:

qapi: Fix crash on missing enum member name (2021-07-15 12:56:41 +0200)

----------------------------------------------------------------
QAPI patches patches for 2021-07-15

----------------------------------------------------------------
Markus Armbruster (1):
qapi: Fix crash on missing enum member name

 scripts/qapi/expr.py                     | 2 +-
 tests/qapi-schema/enum-dict-no-name.err  | 2 ++
 tests/qapi-schema/enum-dict-no-name.json | 2 ++
 tests/qapi-schema/enum-dict-no-name.out  | 0
 4 files changed, 5 insertions(+), 1 deletion(-)
 create mode 100644 tests/qapi-schema/enum-dict-no-name.err
 create mode 100644 tests/qapi-schema/enum-dict-no-name.json
 create mode 100644 tests/qapi-schema/enum-dict-no-name.out
Signature · 1 line
2.31.1
#1 lore raw

[PULL 1/1] qapi: Fix crash on missing enum member name

New test case enum-dict-no-name.json crashes:

    $ python3 scripts/qapi-gen.py tests/qapi-schema/enum-dict-no-name.json
    Traceback (most recent call last):
    [...]
      File "/work/armbru/qemu/scripts/qapi/expr.py", line 458, in check_enum
	member_name = member['name']
    KeyError: 'name'

Root cause: we try to retrieve member 'name' before we check for missing members. With that fixed, we get the expected error "'data' member misses key 'name'".

Fixes 0825f62c842f2c07c5471391c6d7fd3f4fe83732

Message-Id: <[email protected]>

---
 scripts/qapi/expr.py                     | 2 +-
 tests/qapi-schema/enum-dict-no-name.err  | 2 ++
 tests/qapi-schema/enum-dict-no-name.json | 2 ++
 tests/qapi-schema/enum-dict-no-name.out  | 0
 4 files changed, 5 insertions(+), 1 deletion(-)
 create mode 100644 tests/qapi-schema/enum-dict-no-name.err
 create mode 100644 tests/qapi-schema/enum-dict-no-name.json
 create mode 100644 tests/qapi-schema/enum-dict-no-name.out
scripts/qapi/expr.py +1 -1
index 496f7e0333..cf98923fa6 100644
@@ -455,8 +455,8 @@ def check_enum(expr: _JSONObject, info: QAPISourceInfo) -> None:
                   for m in members]
     for member in members:
         source = "'data' member"
-        member_name = member['name']
         check_keys(member, info, source, ['name'], ['if'])
+        member_name = member['name']
         check_name_is_str(member_name, info, source)
         source = "%s '%s'" % (source, member_name)
         # Enum members may start with a digit
tests/qapi-schema/enum-dict-no-name.err new file +2 -0
new file mode 100644
index 0000000000..3ce0c16987
@@ -0,0 +1,2 @@
+enum-dict-no-name.json: In enum 'Enum':
+enum-dict-no-name.json:2: 'data' member misses key 'name'
tests/qapi-schema/enum-dict-no-name.json new file +2 -0
new file mode 100644
index 0000000000..5952a8662e
@@ -0,0 +1,2 @@
+# enum member lacking a name
+{ 'enum': 'Enum', 'data': [ {} ] }
tests/qapi-schema/enum-dict-no-name.out new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
2.31.1
#2 lore raw
In reply to Markus Armbruster
Quoted 7 lines · Markus Armbruster

The following changes since commit a9649a719a44894b81f38dc1c5c1888ee684acef:

Merge remote-tracking branch 'remotes/cleber-gitlab/tags/python-next-pull-request' into staging (2021-07-14 18:09:09 +0100)

are available in the Git repository at:

Quoted 8 lines

git://repo.or.cz/qemu/armbru.git tags/pull-qapi-2021-07-15

for you to fetch changes up to a0c7b99bf75d85b616fa219a7d866fc72970f327:

qapi: Fix crash on missing enum member name (2021-07-15 12:56:41 +0200)

----------------------------------------------------------------
QAPI patches patches for 2021-07-15

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/6.1
for any user-visible changes.

-- PMM