qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v3 15/49] qapi: do not define enumeration value expl


From: Marc-André Lureau
Subject: [Qemu-devel] [PATCH v3 15/49] qapi: do not define enumeration value explicitely
Date: Wed, 21 Mar 2018 12:51:37 +0100

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>
---
 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 60c1d0a783..68a567f53f 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -2032,14 +2032,11 @@ typedef enum %(c_name)s {
 ''',
                 c_name=c_name(name))
 
-    i = 0
     for 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;
-- 
2.16.2.521.g9aa15f885a




reply via email to

[Prev in Thread] Current Thread [Next in Thread]