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

Re: [Xen-devel] [PATCH V5 20/32] libxl IDL: generate code to parse libxl__json_object to libxl_FOO struct

On Tue, 2014-05-13 at 22:54 +0100, Wei Liu wrote:
> libxl_FOO_parse_json functions are generated.
> Note that these functions are used to parse libxl__json_object to
> libxl__FOO struct. They don't consume JSON string.
> Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>

I eyeballed this again and the only query I have is this:

+    if (libxl__json_map_get("enable", o, JSON_STRING)) {
+        x = libxl__json_map_get("enable", o, JSON_STRING);

These two get calls are a bit redundant.

Looking at the code generator I don't think it forces this on you and
you could arrange instead for:
    x = libxl__json_map_get("enable", o, JSON_STRING);
    if (x) {

Perhaps you need to save x in a new local parent so you can restore it
in that case.
    saved_parent = x;
    x = libxl__json_map_get("enable", o, JSON_STRING);
    if (x) {
    x = saved_parent;

(perhaps putting in its own block and declaring saved_parent locally
each time).

+        rc = libxl_defbool_parse_json(gc, x, &p->enable);
+        if (rc)
+            goto out;
+        x = x->parent;
+    }

Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.