WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH V2 02/11] libxl_json, Check the parser status bef

To: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH V2 02/11] libxl_json, Check the parser status before to call parse_complete
From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Date: Mon, 24 Oct 2011 15:59:50 +0100
Cc: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Mon, 24 Oct 2011 08:10:24 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=9eoMVD5Q5W3dMAP+ABQ5g3jlIGu5NuKlTz/8FcS7SvY=; b=Z/nXcgaA1pkMIuE4JWHixfinly70EOlEfxQHL4SQg7MD8wgEGl8RZph9wWZCTYou5K YuMjUAIQ2cD5CYA97PufMtO7T7hi1oZH/TodquSbWg62+P7h+EmevCxCkqB4wOS/zMpw X+xZBpYr1Y/96peimS5qqEOotKgWE77D8Vl8U=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1319449097.3385.165.camel@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1319133573-25891-1-git-send-email-anthony.perard@xxxxxxxxxx> <1319133573-25891-3-git-send-email-anthony.perard@xxxxxxxxxx> <1319449097.3385.165.camel@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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

<Prev in Thread] Current Thread [Next in Thread>