diff mbox

[Xen-devel,V2,3/4] libxl/gentypes.py: generate empty map for None field in keyed-union

Message ID 1397494391.7802.20.camel@dagon.hellion.org.uk
State New
Headers show

Commit Message

Ian Campbell April 14, 2014, 4:53 p.m. UTC
On Thu, 2014-04-10 at 16:26 +0100, Wei Liu wrote:
> Without this the generated JSON is malformed.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

Hold on the Ack...

> +            else:
> +                s += "    yajl_gen_map_open(hand);\n"

ITHM s =...

> +                s += "    if (s != yajl_gen_status_ok)\n"
> +                s += "        goto out;\n"
> +                s += "    yajl_gen_map_close(hand);\n"

and again.

Spotted because the diff of the generated code across the entire series
was as below, the spurious change is pretty obvious in the third hunk.

Ian.

Comments

Ian Campbell April 14, 2014, 5:08 p.m. UTC | #1
On Mon, 2014-04-14 at 17:59 +0100, Wei Liu wrote:
> On Mon, Apr 14, 2014 at 05:53:11PM +0100, Ian Campbell wrote:
> > On Thu, 2014-04-10 at 16:26 +0100, Wei Liu wrote:
> > > Without this the generated JSON is malformed.
> > > 
> > > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > 
> > Hold on the Ack...
> > 
> > > +            else:
> > > +                s += "    yajl_gen_map_open(hand);\n"
> > 
> > ITHM s =...
> > 
> > > +                s += "    if (s != yajl_gen_status_ok)\n"
> > > +                s += "        goto out;\n"
> > > +                s += "    yajl_gen_map_close(hand);\n"
> > 
> > and again.
> > 
> > Spotted because the diff of the generated code across the entire series
> > was as below, the spurious change is pretty obvious in the third hunk.
> > 
> 
> I should've stolen your handy script earlier!

~ianc/xen-build-tools/libxl-idl-* if you still want to...

> This one should be correct.

Agreed, you can have that Ack back ;-)
Wei Liu April 14, 2014, 5:11 p.m. UTC | #2
On Mon, Apr 14, 2014 at 06:08:50PM +0100, Ian Campbell wrote:
> On Mon, 2014-04-14 at 17:59 +0100, Wei Liu wrote:
> > On Mon, Apr 14, 2014 at 05:53:11PM +0100, Ian Campbell wrote:
> > > On Thu, 2014-04-10 at 16:26 +0100, Wei Liu wrote:
> > > > Without this the generated JSON is malformed.
> > > > 
> > > > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > > 
> > > Hold on the Ack...
> > > 
> > > > +            else:
> > > > +                s += "    yajl_gen_map_open(hand);\n"
> > > 
> > > ITHM s =...
> > > 
> > > > +                s += "    if (s != yajl_gen_status_ok)\n"
> > > > +                s += "        goto out;\n"
> > > > +                s += "    yajl_gen_map_close(hand);\n"
> > > 
> > > and again.
> > > 
> > > Spotted because the diff of the generated code across the entire series
> > > was as below, the spurious change is pretty obvious in the third hunk.
> > > 
> > 
> > I should've stolen your handy script earlier!
> 
> ~ianc/xen-build-tools/libxl-idl-* if you still want to...
> 
> > This one should be correct.
> 
> Agreed, you can have that Ack back ;-)
> 

Do you want me to resend the whole series with all Acks folded in?

Wei.
Ian Jackson April 15, 2014, 10:29 a.m. UTC | #3
Ian Campbell writes ("Re: [PATCH V2 3/4] libxl/gentypes.py: generate empty map for None field in keyed-union"):
> On Mon, 2014-04-14 at 17:59 +0100, Wei Liu wrote:
> > I should've stolen your handy script earlier!
> 
> ~ianc/xen-build-tools/libxl-idl-* if you still want to...

Can we check this into the tree ?

Ian.
Ian Campbell April 15, 2014, 10:32 a.m. UTC | #4
On Tue, 2014-04-15 at 11:29 +0100, Ian Jackson wrote:
> Ian Campbell writes ("Re: [PATCH V2 3/4] libxl/gentypes.py: generate empty map for None field in keyed-union"):
> > On Mon, 2014-04-14 at 17:59 +0100, Wei Liu wrote:
> > > I should've stolen your handy script earlier!
> > 
> > ~ianc/xen-build-tools/libxl-idl-* if you still want to...
> 
> Can we check this into the tree ?

They are pretty dumb, but we can if you like. Here they are for
prejudgement...


----- libxl-idl-save-baseline ------
#!/bin/bash

set -e

for i in tools/libxl/_libxl_types.c tools/libxl/_libxl_types.h tools/libxl/_libxl_types_json.h \
         tools/libxl/_libxl_types_internal.c tools/libxl/_libxl_types_internal.h tools/libxl/_libxl_types_internal_json.h \
         tools/python/xen/lowlevel/xl/_pyxl_types.h tools/python/xen/lowlevel/xl/_pyxl_types.c \
         tools/ocaml/libs/xl/_libxl_types.inc  tools/ocaml/libs/xl/_libxl_types.mli.in  tools/ocaml/libs/xl/_libxl_types.ml.in \
         tools/libxl/testidl.c \
tools/libxl/_libxl_save_msgs_callout.c tools/libxl/_libxl_save_msgs_callout.h tools/libxl/_libxl_save_msgs_helper.c tools/libxl/_libxl_save_msgs_helper.h ; do

    bak=$(echo $i | sed -e 's,[^/]*/\(_libxl\|_pyxl\|testidl\),&_BACKUP,g')
    if [ -e "$i" ] ; then
	cp -v "$i" "$bak"
    else
	rm -f "$bak"
	echo touch "$bak"
	touch "$bak"
    fi
done

----- libxl-idl-compare-baseline -----
#!/bin/bash

set -e

for i in tools/libxl/_libxl_types.c tools/libxl/_libxl_types.h tools/libxl/_libxl_types_json.h \
         tools/libxl/_libxl_types_internal.c tools/libxl/_libxl_types_internal.h tools/libxl/_libxl_types_internal_json.h \
         tools/python/xen/lowlevel/xl/_pyxl_types.h tools/python/xen/lowlevel/xl/_pyxl_types.c \
         tools/ocaml/libs/xl/_libxl_types.inc  tools/ocaml/libs/xl/_libxl_types.mli.in  tools/ocaml/libs/xl/_libxl_types.ml.in \
         tools/libxl/testidl.c \
tools/libxl/_libxl_save_msgs_callout.c tools/libxl/_libxl_save_msgs_callout.h tools/libxl/_libxl_save_msgs_helper.c tools/libxl/_libxl_save_msgs_helper.h ; do

    bak=$(echo $i | sed -e 's,[^/]*/\(_libxl\|_pyxl\|testidl\),&_BACKUP,g')

    diff -puN $bak $i || true
done
Ian Jackson April 15, 2014, 11:29 a.m. UTC | #5
Ian Campbell writes ("Re: [PATCH V2 3/4] libxl/gentypes.py: generate empty map for None field in keyed-union"):
> They are pretty dumb, but we can if you like. Here they are for
> prejudgement...

Quite ugly, I agree.  But I think it's better to have them in-tree
where they can be shared and improved, than floating about on some NFS
filer in the Citrix Cambridge office.

TBH it might be possible to do in the Makefile but I think that's a
task for another day.

Ian.
Ian Campbell April 16, 2014, 4:30 p.m. UTC | #6
On Mon, 2014-04-14 at 18:11 +0100, Wei Liu wrote:
> On Mon, Apr 14, 2014 at 06:08:50PM +0100, Ian Campbell wrote:
> > On Mon, 2014-04-14 at 17:59 +0100, Wei Liu wrote:
> > > On Mon, Apr 14, 2014 at 05:53:11PM +0100, Ian Campbell wrote:
> > > > On Thu, 2014-04-10 at 16:26 +0100, Wei Liu wrote:
> > > > > Without this the generated JSON is malformed.
> > > > > 
> > > > > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > > > 
> > > > Hold on the Ack...
> > > > 
> > > > > +            else:
> > > > > +                s += "    yajl_gen_map_open(hand);\n"
> > > > 
> > > > ITHM s =...
> > > > 
> > > > > +                s += "    if (s != yajl_gen_status_ok)\n"
> > > > > +                s += "        goto out;\n"
> > > > > +                s += "    yajl_gen_map_close(hand);\n"
> > > > 
> > > > and again.
> > > > 
> > > > Spotted because the diff of the generated code across the entire series
> > > > was as below, the spurious change is pretty obvious in the third hunk.
> > > > 
> > > 
> > > I should've stolen your handy script earlier!
> > 
> > ~ianc/xen-build-tools/libxl-idl-* if you still want to...
> > 
> > > This one should be correct.
> > 
> > Agreed, you can have that Ack back ;-)
> > 
> 
> Do you want me to resend the whole series with all Acks folded in?

No need, I've applied. Please check I got the right versions of
everything!
Wei Liu April 16, 2014, 4:36 p.m. UTC | #7
On Wed, Apr 16, 2014 at 05:30:21PM +0100, Ian Campbell wrote:
[...]
> No need, I've applied. Please check I got the right versions of
> everything!
> 

I've checked. You checked in the correct version. Thanks.
diff mbox

Patch

--- tools/libxl/_libxl_BACKUP_types.c	2014-04-14 17:51:03.000000000 +0100
+++ tools/libxl/_libxl_types.c	2014-04-14 17:51:11.000000000 +0100
@@ -2523,6 +2523,12 @@  yajl_gen_status libxl_domain_build_info_
             goto out;
         break;
     case LIBXL_DOMAIN_TYPE_INVALID:
+        yajl_gen_map_open(hand);
+        if (s != yajl_gen_status_ok)
+            goto out;
+        yajl_gen_map_close(hand);
+        if (s != yajl_gen_status_ok)
+            goto out;
         break;
     }
     s = yajl_gen_map_close(hand);
@@ -3631,9 +3637,6 @@  yajl_gen_status libxl_event_gen_json(yaj
     s = yajl_gen_map_open(hand);
     if (s != yajl_gen_status_ok)
         goto out;
-    s = yajl_gen_string(hand, (const unsigned char *)"link", sizeof("link")-1);
-    if (s != yajl_gen_status_ok)
-        goto out;
     s = yajl_gen_string(hand, (const unsigned char *)"domid", sizeof("domid")-1);
     if (s != yajl_gen_status_ok)
         goto out;
@@ -3713,10 +3716,10 @@  yajl_gen_status libxl_event_gen_json(yaj
             goto out;
         break;
     case LIBXL_EVENT_TYPE_DOMAIN_CREATE_CONSOLE_AVAILABLE:
-        s = yajl_gen_map_open(hand);
+        yajl_gen_map_open(hand);
         if (s != yajl_gen_status_ok)
             goto out;
-        s = yajl_gen_map_close(hand);
+        yajl_gen_map_close(hand);
         if (s != yajl_gen_status_ok)
             goto out;
         break;
--- tools/libxl/_libxl_BACKUP_types.h	2014-04-14 17:51:03.000000000 +0100
+++ tools/libxl/_libxl_types.h	2014-04-14 17:51:11.000000000 +0100
@@ -694,8 +694,6 @@  typedef struct libxl_event {
         struct {
             int rc;
         } operation_complete;
-        struct {
-        } domain_create_console_available;
     } u;
 } libxl_event;
 void libxl_event_dispose(libxl_event *p);