From: Ian Campbell Subject: Re: [PATCH V5 20/32] libxl IDL: generate code to parse libxl__json_object to libxl_FOO struct Date: Tue, 20 May 2014 14:35:02 +0100 Message-ID: <1400592902.6946.53.camel@kazak.uk.xensource.com> References: <1400018054-26038-1-git-send-email-wei.liu2@citrix.com> <1400018054-26038-21-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1400018054-26038-21-git-send-email-wei.liu2@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu Cc: ian.jackson@eu.citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org 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 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; + }