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

Re: [Xen-devel] [PATCH V2 02/11] libxl_json, Check the parser status before to call parse_complete



On Mon, Oct 24, 2011 at 10:38, Ian Campbell <Ian.Campbell@xxxxxxxxxx> wrote:
> On Thu, 2011-10-20 at 18:59 +0100, Anthony PERARD wrote:
>> Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
>> ---
>> Âtools/libxl/libxl_json.c | Â Â4 +++-
>> Â1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/tools/libxl/libxl_json.c b/tools/libxl/libxl_json.c
>> index 11f65fc..c743114 100644
>> --- a/tools/libxl/libxl_json.c
>> +++ b/tools/libxl/libxl_json.c
>> @@ -744,7 +744,9 @@ libxl__json_object *libxl__json_parse(libxl__gc *gc, 
>> const char *s)
>> Â Â Â Â Âyajl_ctx.hand = yajl_alloc(&callbacks, &cfg, NULL, &yajl_ctx);
>> Â Â Â}
>> Â Â Âstatus = yajl_parse(yajl_ctx.hand, (const unsigned char *)s, strlen(s));
>> - Â Âstatus = yajl_parse_complete(yajl_ctx.hand);
>> + Â Âif (status == yajl_status_ok) {
>> + Â Â Â Âstatus = yajl_parse_complete(yajl_ctx.hand);
>> + Â Â}
>>
>> Â Â Âif (status == yajl_status_ok) {
>
> You now have two of these checks back-to-back. I guess they could be
> combined?

:(, I do not see how I could combine them. Because, if I call
parse_complete() after a parse() fail, I do not see a good error
message(yajl forget a bit of his status). And parse_complete() could
fail too, so I want to check is status too.
So, I check the same status twice, only in case of error.

(the second if(status) will print the error messages.)

-- 
Anthony PERARD

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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