summaryrefslogtreecommitdiffstats
path: root/scripts/qapi.py
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2015-11-18 01:52:52 -0700
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 19:28:19 -0600
commite2798684ad14e1c2c40927b882560c6c8f74256f (patch)
tree9d9782a9477b330afce703a1ec73dedc10e5fbf3 /scripts/qapi.py
parent6bcb8ede6460b9d0345f0eaa5a213c440f8eabe3 (diff)
downloadhqemu-e2798684ad14e1c2c40927b882560c6c8f74256f.zip
hqemu-e2798684ad14e1c2c40927b882560c6c8f74256f.tar.gz
qapi: Fix c_name() munging
The method c_name() is supposed to do two different actions: munge '-' into '_', and add a 'q_' prefix to ticklish names. But it did these steps out of order, making it possible to submit input that is not ticklish until after munging, where the output then lacked the desired prefix. The failure is exposed easily if you have a compiler that recognizes C11 keywords, and try to name a member '_Thread-local', as it would result in trying to compile the declaration 'uint64_t _Thread_local;' which is not valid. However, this name violates our conventions (ultimately, want to enforce that no qapi names start with single underscore), so the test is slightly weaker by instead testing 'wchar-t'; the declaration 'uint64_t wchar_t;' is valid in C (where wchar_t is only a typedef) but would fail with a C++ compiler (where it is a keyword). Fix things by reversing the order of actions within c_name(). Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1447836791-369-18-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'scripts/qapi.py')
-rw-r--r--scripts/qapi.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 4870326..d2ce9b3 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -1482,10 +1482,11 @@ def c_name(name, protect=True):
'not_eq', 'or', 'or_eq', 'xor', 'xor_eq'])
# namespace pollution:
polluted_words = set(['unix', 'errno'])
+ name = name.translate(c_name_trans)
if protect and (name in c89_words | c99_words | c11_words | gcc_words
| cpp_words | polluted_words):
return "q_" + name
- return name.translate(c_name_trans)
+ return name
eatspace = '\033EATSPACE.'
pointer_suffix = ' *' + eatspace
OpenPOWER on IntegriCloud