On Thu, Feb 18, 2016 at 08:26:44AM +0100, Markus Armbruster wrote: > Peter Xu <pet...@redhat.com> writes: > > > Changes from v7: > > - patch 8: use s->dump_info.page_size not TARGET_PAGE_SIZE > > - patch 10: change DUMP_STATUS_MAX to DUMP_STATUS__MAX (this is to > > fix compile error for rebasing to latest master branch, still do > > not know why we need this change from generating "_MAX" to > > "__MAX" for enum types...) > > Don't ask yourself why something was done, ask git :)
Sorry for my laziness... But it seems that it luckily brings me another "-S" git trick. Lots of things to learn. :-) > > $ git-log -S__MAX > [...] > commit 7fb1cf1606c78c9d5b538f29176fd5a101726a9d > Author: Eric Blake <ebl...@redhat.com> > Date: Wed Nov 18 01:52:57 2015 -0700 > > ---> qapi: Don't let implicit enum MAX member collide > > Now that we guarantee the user doesn't have any enum values > beginning with a single underscore, we can use that for our > own purposes. Renaming ENUM_MAX to ENUM__MAX makes it obvious > that the sentinel is generated. > > This patch was mostly generated by applying a temporary patch: > > |diff --git a/scripts/qapi.py b/scripts/qapi.py > |index e6d014b..b862ec9 100644 > |--- a/scripts/qapi.py > |+++ b/scripts/qapi.py > |@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] = { > | max_index = c_enum_const(name, 'MAX', prefix) > | ret += mcgen(''' > | [%(max_index)s] = NULL, > |+// %(max_index)s > | }; > | ''', > | max_index=max_index) > > then running: > > $ cat qapi-{types,event}.c tests/test-qapi-types.c | > sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list > $ git grep -l _MAX | xargs sed -i -f list > > The only things not generated are the changes in scripts/qapi.py. > > Rejecting enum members named 'MAX' is now useless, and will be dropped > in the next patch. > > Signed-off-by: Eric Blake <ebl...@redhat.com> > Message-Id: <1447836791-369-23-git-send-email-ebl...@redhat.com> > Reviewed-by: Juan Quintela <quint...@redhat.com> > [Rebased to current master, commit message tweaked] > Signed-off-by: Markus Armbruster <arm...@redhat.com> > > I guess this isn't perfectly clear without more context, so let me add > some. > > The implicit FOO_MAX could collide with the user's FOO_MAX for QAPI > enumeration values 'max', or case variations thereof. Commit cf39359 > added extra code to catch that. > > Renaming the implict FOO_MAX to FOO__MAX removes the need for the > special rule "you can't use 'max' as an enumeration value", because the > general rule "names starting with '_' are reserved" suffices then. > > Fewer rules is better. Yah. The commit is reasonable and explanation is clear. Thanks! Peter > > [...]