From 61ad7b38244e58c782c9c9662050c418bab491da Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 19 Feb 2018 19:28:46 -0500 Subject: [PATCH] qapi: Reserve 'u' member name Now that we have separated union tag values from colliding with non-variant C names, by naming the union 'u', we should reserve this name for our use. Note that we want to forbid 'u' even in a struct with no variants, because it is possible for a future qemu release to extend QMP in a backwards-compatible manner while converting from a struct to a flat union. Fortunately, no existing clients were using this member name. If we ever find the need for QMP to have a member 'u', we could at that time relax things, perhaps by having c_name() munge the QMP member to 'q_u'. Note that we cannot forbid 'u' everywhere (by adding the rejection code to check_name()), because the existing QKeyCode enum already uses it; therefore we only reserve it as a struct type member name. Backports commit 5e59baf90a72cd25d38a3134edc029f4f022da74 from qemu --- qemu/scripts/qapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu/scripts/qapi.py b/qemu/scripts/qapi.py index 9e45e41b..7afb5b81 100644 --- a/qemu/scripts/qapi.py +++ b/qemu/scripts/qapi.py @@ -490,7 +490,7 @@ def check_type(expr_info, source, value, allow_array=False, for (key, arg) in value.items(): check_name(expr_info, "Member of %s" % source, key, allow_optional=allow_optional) - if c_name(key, False).startswith('has_'): + if c_name(key, False) == 'u' or c_name(key, False).startswith('has_'): raise QAPIExprError(expr_info, "Member of %s uses reserved name '%s'" % (source, key))