]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
libxl/gentypes: fix generating array of enums
authorWei Liu <wei.liu2@citrix.com>
Mon, 2 Oct 2017 11:48:28 +0000 (12:48 +0100)
committerWei Liu <wei.liu2@citrix.com>
Wed, 4 Oct 2017 10:09:46 +0000 (11:09 +0100)
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 <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/gentypes.py

index 76aca76aaae8d457087f7bc1180d384b383aa34d..88e5c5f30e5940e778d8f543a796d151f1c42e26 100644 (file)
@@ -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"