From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXVxo-0005hY-Go for qemu-devel@nongnu.org; Thu, 13 Dec 2018 13:44:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXVxl-0002Ip-Rw for qemu-devel@nongnu.org; Thu, 13 Dec 2018 13:43:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33508) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gXVxj-0001eR-Od for qemu-devel@nongnu.org; Thu, 13 Dec 2018 13:43:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73EB588E50 for ; Thu, 13 Dec 2018 18:43:49 +0000 (UTC) From: Markus Armbruster Date: Thu, 13 Dec 2018 19:43:23 +0100 Message-Id: <20181213184340.24037-16-armbru@redhat.com> In-Reply-To: <20181213184340.24037-1-armbru@redhat.com> References: <20181213184340.24037-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 15/32] qapi: Do not define enumeration value explicitly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 Lureau The generated C enumeration types explicitly set the enumeration constants to 0, 1, 2, ... That's exactly what you get when you don't supply values. Drop the explicit values. No change now, but it will avoid gaps in the values when we later add support for 'if' conditions. Avoiding such gaps will save us the trouble of changing the ENUM_lookup[] tables to work without a sentinel. We'll have to take care to ensure the headers required by the 'if' conditions get always included before the generated QAPI code. Fortunately, our convention to include "qemu/osdep.h" first in any .c ensures that's the case for our CONFIG_FOO macros. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster Message-Id: <20181213123724.4866-2-marcandre.lureau@redhat.com> Signed-off-by: Markus Armbruster --- scripts/qapi/common.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 046b7e5681..55c914ec44 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -2045,14 +2045,11 @@ typedef enum %(c_name)s { ''', c_name=3Dc_name(name)) =20 - i =3D 0 for value in enum_values: ret +=3D mcgen(''' - %(c_enum)s =3D %(i)d, + %(c_enum)s, ''', - c_enum=3Dc_enum_const(name, value, prefix), - i=3Di) - i +=3D 1 + c_enum=3Dc_enum_const(name, value, prefix)) =20 ret +=3D mcgen(''' } %(c_name)s; --=20 2.17.2