From: Anthony PERARD Date: Thu, 22 Nov 2018 18:38:39 +0000 (+0000) Subject: libxl: Add wrapper around libxl__json_object_to_json JSON X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~2658 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0778f1a499a5d398feeb53332efa48073b998172;p=xen.git 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 Acked-by: Ian Jackson --- 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)) ? : "") /* Based on /local/domain/$domid/dm-version xenstore key * default is qemu xen traditional */