[xen staging] libxl: Add wrapper around libxl__json_object_to_json JSON

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen staging] libxl: Add wrapper around libxl__json_object_to_json JSON

patchbot
commit 0778f1a499a5d398feeb53332efa48073b998172
Author:     Anthony PERARD <[hidden email]>
AuthorDate: Thu Nov 22 18:38:39 2018 +0000
Commit:     Wei Liu <[hidden email]>
CommitDate: Fri Jan 11 14:57:35 2019 +0000

    libxl: Add wrapper around libxl__json_object_to_json JSON
   
    That wrapper is going to be used to safely log a json_object, as
    libxl__json_object_to_json return NULL on error. In the error case,
    JSON() will return an invalid json string.
   
    Signed-off-by: Anthony PERARD <[hidden email]>
    Acked-by: Ian Jackson <[hidden email]>
---
 tools/libxl/libxl_internal.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index aa9059ffec..16e6eb6c5e 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -2046,6 +2046,9 @@ _hidden libxl__json_object *libxl__json_parse(libxl__gc *gc_opt, const char *s);
 
 _hidden char *libxl__json_object_to_json(libxl__gc *gc,
                                          const libxl__json_object *args);
+/* Always return a valid string, but invalid json on error. */
+#define JSON(o) \
+    (libxl__json_object_to_json(gc, (o)) ? : "<invalid-json-object>")
 
   /* Based on /local/domain/$domid/dm-version xenstore key
    * default is qemu xen traditional */
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog