[xen master] libxl/gentypes: fix generating array of enums

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen master] libxl/gentypes: fix generating array of enums

patchbot
commit a71a96a41e273f3943119965a8cb75550cca6ba8
Author:     Wei Liu <[hidden email]>
AuthorDate: Mon Oct 2 12:48:28 2017 +0100
Commit:     Wei Liu <[hidden email]>
CommitDate: Wed Oct 4 11:09:46 2017 +0100

    libxl/gentypes: fix generating array of enums
   
    There is no reason to hardcode "x" in code. Use "w" which is passed
    by the higher level.
   
    This change requires us to allow "x" to be unused so that the
    top-level enum parse_json functions continue to compile.
   
    Signed-off-by: Wei Liu <[hidden email]>
    Acked-by: Ian Jackson <[hidden email]>
---
 tools/libxl/gentypes.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py
index 76aca76..88e5c5f 100644
--- a/tools/libxl/gentypes.py
+++ b/tools/libxl/gentypes.py
@@ -432,7 +432,7 @@ def libxl_C_type_parse_json(ty, w, v, indent = "    ", parent = None, discrimina
     s = ""
     if parent is None:
         s += "int rc = 0;\n"
-        s += "const libxl__json_object *x = o;\n"
+        s += "const libxl__json_object *x __attribute__((__unused__)) = o;\n"
 
     if isinstance(ty, idl.Array):
         if parent is None:
@@ -467,11 +467,11 @@ def libxl_C_type_parse_json(ty, w, v, indent = "    ", parent = None, discrimina
             raise Exception("Only KeyedUnion can have discriminator")
         s += "{\n"
         s += "    const char *enum_str;\n"
-        s += "    if (!libxl__json_object_is_string(x)) {\n"
+        s += "    if (!libxl__json_object_is_string(%s)) {\n" % w
         s += "        rc = -1;\n"
         s += "        goto out;\n"
         s += "    }\n"
-        s += "    enum_str = libxl__json_object_get_string(x);\n"
+        s += "    enum_str = libxl__json_object_get_string(%s);\n" % w
         s += "    rc = %s_from_string(enum_str, %s);\n" % (ty.typename, ty.pass_arg(v, parent is None, idl.PASS_BY_REFERENCE))
         s += "    if (rc)\n"
         s += "        goto out;\n"
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog