xen-devel
Re: [Xen-devel] [PATCH V2 02/11] libxl_json, Check the parser status bef
On Mon, 2011-10-24 at 15:59 +0100, Anthony PERARD wrote:
> 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.)
I totally missed that status was updated inside the first if, sorry!
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
<Prev in Thread] |
Current Thread |
[Next in Thread>
|
- Re: [Xen-devel] [PATCH V2 04/11] libxl, Introduce dm-version xenstore key., (continued)
- [Xen-devel] [PATCH V2 06/11] libxl_qmp, Introduce list of arguments to qmp_send, Anthony PERARD
- [Xen-devel] [PATCH V2 07/11] libxl_qmp, Always insert a command id in the callback_list., Anthony PERARD
- [Xen-devel] [PATCH V2 10/11] libxl_qmp, Introduce libxl__qmp_pci_add., Anthony PERARD
- [Xen-devel] [PATCH V2 11/11] libxl, Use QMP to insert a passthrough device when using upstream QEMU, Anthony PERARD
- [Xen-devel] [PATCH V2 02/11] libxl_json, Check the parser status before to call parse_complete, Anthony PERARD
- Re: [Xen-devel] [PATCH V2 02/11] libxl_json, Check the parser status before to call parse_complete, Ian Jackson
- [Xen-devel] [PATCH V2 08/11] libxl_qmp, Introduce qmp_request_handle., Anthony PERARD
- [Xen-devel] [PATCH V2 09/11] libxl_json, Handle number abrove LONG_MAX., Anthony PERARD
- [Xen-devel] [PATCH V2 05/11] libxl_qmp, Introduce an opaque argument to the callbacks., Anthony PERARD
|
|
|