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

[Xen-changelog] [xen-unstable] libxl_json: Replace JSON_TRUE/FALSE by JSON_BOOL.


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Mon, 08 Oct 2012 15:55:10 +0000
  • Delivery-date: Mon, 08 Oct 2012 15:55:18 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Anthony PERARD <anthony.perard@xxxxxxxxxx>
# Date 1349693131 -3600
# Node ID 3f71aab0e2774ded0c5a03436c364fb031ba9aa0
# Parent  4a6d5d8cba4fc44f9bbda201188885868604b8e8
libxl_json: Replace JSON_TRUE/FALSE by JSON_BOOL.

Those two JSON_TRUE and JSON_FALSE were types of node. But it's better
to have a unique JSON_BOOL type.

Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---


diff -r 4a6d5d8cba4f -r 3f71aab0e277 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Mon Oct 08 11:45:30 2012 +0100
+++ b/tools/libxl/libxl_internal.h      Mon Oct 08 11:45:31 2012 +0100
@@ -1433,8 +1433,7 @@ _hidden yajl_gen_status libxl__yajl_gen_
 
 typedef enum {
     JSON_NULL,
-    JSON_TRUE,
-    JSON_FALSE,
+    JSON_BOOL,
     JSON_INTEGER,
     JSON_DOUBLE,
     /* number is store in string, it's too big to be a long long or a double */
@@ -1448,6 +1447,7 @@ typedef enum {
 typedef struct libxl__json_object {
     libxl__json_node_type type;
     union {
+        bool b;
         long long i;
         double d;
         char *string;
@@ -1466,6 +1466,10 @@ typedef struct {
 
 typedef struct libxl__yajl_ctx libxl__yajl_ctx;
 
+static inline bool libxl__json_object_is_bool(const libxl__json_object *o)
+{
+    return o != NULL && o->type == JSON_BOOL;
+}
 static inline bool libxl__json_object_is_string(const libxl__json_object *o)
 {
     return o != NULL && o->type == JSON_STRING;
@@ -1483,6 +1487,13 @@ static inline bool libxl__json_object_is
     return o != NULL && o->type == JSON_ARRAY;
 }
 
+static inline bool libxl__json_object_get_bool(const libxl__json_object *o)
+{
+    if (libxl__json_object_is_bool(o))
+        return o->u.b;
+    else
+        return false;
+}
 static inline
 const char *libxl__json_object_get_string(const libxl__json_object *o)
 {
diff -r 4a6d5d8cba4f -r 3f71aab0e277 tools/libxl/libxl_json.c
--- a/tools/libxl/libxl_json.c  Mon Oct 08 11:45:30 2012 +0100
+++ b/tools/libxl/libxl_json.c  Mon Oct 08 11:45:31 2012 +0100
@@ -394,8 +394,8 @@ static int json_callback_boolean(void *o
 
     DEBUG_GEN_VALUE(ctx, bool, boolean);
 
-    obj = libxl__json_object_alloc(ctx->gc,
-                                   boolean ? JSON_TRUE : JSON_FALSE);
+    obj = libxl__json_object_alloc(ctx->gc, JSON_BOOL);
+    obj->u.b = boolean;
 
     if (libxl__json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
         return 0;
diff -r 4a6d5d8cba4f -r 3f71aab0e277 tools/libxl/libxl_qmp.c
--- a/tools/libxl/libxl_qmp.c   Mon Oct 08 11:45:30 2012 +0100
+++ b/tools/libxl/libxl_qmp.c   Mon Oct 08 11:45:31 2012 +0100
@@ -178,7 +178,8 @@ static int qmp_register_vnc_callback(lib
         goto out;
     }
 
-    if (libxl__json_map_get("enabled", o, JSON_FALSE)) {
+    obj = libxl__json_map_get("enabled", o, JSON_BOOL);
+    if (!obj || !libxl__json_object_get_bool(obj)) {
         rc = 0;
         goto out;
     }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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