diff options
author | Eric Blake <eblake@redhat.com> | 2015-11-18 01:52:56 -0700 |
---|---|---|
committer | Timothy Pearson <tpearson@raptorengineering.com> | 2019-11-29 19:28:19 -0600 |
commit | 197c6e2298b294de0b2350c7dd9d78c2ea7a2cf0 (patch) | |
tree | d0dffd7c28cfa7e54d5c2d3e567d11b515ac1713 /include/migration/migration.h | |
parent | 355df76ceb030055e6582275b56ea2ad42f66939 (diff) | |
download | hqemu-197c6e2298b294de0b2350c7dd9d78c2ea7a2cf0.zip hqemu-197c6e2298b294de0b2350c7dd9d78c2ea7a2cf0.tar.gz |
qapi: Tighten the regex on valid names
We already documented that qapi names should match specific
patterns (such as starting with a letter unless it was an enum
value or a downstream extension). Tighten that from a suggestion
into a hard requirement, which frees up names beginning with a
single underscore for qapi internal usage.
The tighter regex doesn't forbid everything insane that a user
could provide (for example, a user could name a type 'Foo-lookup'
to collide with the generated 'Foo_lookup[]' for an enum 'Foo'),
but does a good job at protecting the most obvious uses, and
also happens to reserve single leading underscore for later use.
The handling of enum values starting with a digit is tricky:
commit 9fb081e introduced a subtle bug by using c_name() on
a munged value, which would allow an enum to include the
member 'q-int' in spite of our reservation. Furthermore,
munging with a leading '_' would fail our tighter regex. So
fix it by only munging for leading digits (which are never
ticklish in c_name()) and by using a different prefix (I
picked 'D', although any letter should do).
Add new tests, reserved-member-underscore and reserved-enum-q,
to demonstrate the tighter checking.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447836791-369-22-git-send-email-eblake@redhat.com>
Message-Id: <1447883135-18020-1-git-send-email-eblake@redhat.com>
[Eric's fixup squashed in]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'include/migration/migration.h')
0 files changed, 0 insertions, 0 deletions