Received: from eggs.gnu.org ([2001:4830:134:3::10]:46311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWIzF-0001G0-3I for qemu-devel@nongnu.org; Thu, 18 Feb 2016 02:26:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWIzB-0000h1-26 for qemu-devel@nongnu.org; Thu, 18 Feb 2016 02:26:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50050) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWIzA-0000gw-TG for qemu-devel@nongnu.org; Thu, 18 Feb 2016 02:26:48 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id B6D3FC000655 for ; Thu, 18 Feb 2016 07:26:47 +0000 (UTC) From: Markus Armbruster References: <1455772616-8668-1-git-send-email-peterx@redhat.com> Date: Thu, 18 Feb 2016 08:26:44 +0100 In-Reply-To: <1455772616-8668-1-git-send-email-peterx@redhat.com> (Peter Xu's message of "Thu, 18 Feb 2016 13:16:45 +0800") Message-ID: <87a8mymqbv.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v7 00/11] Add basic "detach" support for dump-guest-memory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Xu Cc: drjones@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com, lersek@redhat.com Peter Xu 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 :) $ git-log -S__MAX [...] commit 7fb1cf1606c78c9d5b538f29176fd5a101726a9d Author: Eric Blake 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 Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com> Reviewed-by: Juan Quintela [Rebased to current master, commit message tweaked] Signed-off-by: Markus Armbruster 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. [...]