|
From: | Philippe Mathieu-Daudé |
Subject: | Re: [Qemu-devel] [PATCH v2 28/54] qapi: do not define enumeration value explicitely |
Date: | Tue, 22 Aug 2017 11:00:19 -0300 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
On 08/22/2017 10:22 AM, Marc-André Lureau wrote:
The C standard has the initial value at 0 and the subsequent values incremented by 1. No need to set this explicitely. This will prevent from artificial "gaps" when compiling out some enum values and having unnecessarily large MAX values & enums arrays. Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
--- scripts/qapi.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 52099332f1..9d075440d3 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -1979,14 +1979,11 @@ typedef enum %(c_name)s { ''', c_name=c_name(name))- i = 0for value in enum_values: ret += mcgen(''' - %(c_enum)s = %(i)d, + %(c_enum)s, ''', - c_enum=c_enum_const(name, value, prefix), - i=i) - i += 1 + c_enum=c_enum_const(name, value, prefix))ret += mcgen('''} %(c_name)s;
[Prev in Thread] | Current Thread | [Next in Thread] |