xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: xen-devel@lists.xen.org
Cc: Wei Liu <wei.liu2@citrix.com>,
	ian.jackson@eu.citrix.com, ian.campbell@citrix.com
Subject: [PATCH V2 2/4] libxl_json: fix JSON parser debug code
Date: Thu, 10 Apr 2014 16:26:32 +0100	[thread overview]
Message-ID: <1397143594-15308-3-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1397143594-15308-1-git-send-email-wei.liu2@citrix.com>

Two changes included:
1. implement DEBUG_GEN_ALLOC for YAJL2
2. use size_t for variable "len"

without these two fixes it fails to compile when DEBUG_ANSWER is
defined.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/libxl_json.c |   17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxl_json.c b/tools/libxl/libxl_json.c
index 989ac3f..3ea56a4 100644
--- a/tools/libxl/libxl_json.c
+++ b/tools/libxl/libxl_json.c
@@ -34,11 +34,20 @@ struct libxl__yajl_ctx {
 };
 
 #ifdef DEBUG_ANSWER
-#  define DEBUG_GEN_ALLOC(ctx) \
-    if ((ctx)->g == NULL) { \
-        yajl_gen_config conf = { 1, "  " }; \
+#if YAJL_VERSION < 20000
+#  define DEBUG_GEN_ALLOC(ctx)                  \
+    if ((ctx)->g == NULL) {                     \
+        yajl_gen_config conf = { 1, "  " };     \
         (ctx)->g = yajl_gen_alloc(&conf, NULL); \
     }
+#else  /* YAJL2 */
+#  define DEBUG_GEN_ALLOC(ctx)                                    \
+    if ((ctx)->g == NULL) {                                       \
+        (ctx)->g = yajl_gen_alloc(NULL);                          \
+        yajl_gen_config((ctx)->g, yajl_gen_beautify, 1);          \
+        yajl_gen_config((ctx)->g, yajl_gen_indent_string, "  ");  \
+    }
+#endif
 #  define DEBUG_GEN_FREE(ctx) \
     if ((ctx)->g) yajl_gen_free((ctx)->g)
 #  define DEBUG_GEN(ctx, type)              yajl_gen_##type(ctx->g)
@@ -48,7 +57,7 @@ struct libxl__yajl_ctx {
 #  define DEBUG_GEN_REPORT(yajl_ctx) \
     do { \
         const unsigned char *buf = NULL; \
-        unsigned int len = 0; \
+        size_t len = 0; \
         yajl_gen_get_buf((yajl_ctx)->g, &buf, &len); \
         LIBXL__LOG(libxl__gc_owner((yajl_ctx)->gc), \
                    LIBXL__LOG_DEBUG, "response:\n%s", buf); \
-- 
1.7.10.4

  parent reply	other threads:[~2014-04-10 15:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-10 15:26 [PATCH V2 0/4] libxl: fixes for JSON infrastructure Wei Liu
2014-04-10 15:26 ` [PATCH V2 1/4] libxl/gentypes.py: don't generate JSON for private type(s) Wei Liu
2014-04-14 16:46   ` Ian Campbell
2014-04-10 15:26 ` Wei Liu [this message]
2014-04-14 16:47   ` [PATCH V2 2/4] libxl_json: fix JSON parser debug code Ian Campbell
2014-04-10 15:26 ` [PATCH V2 3/4] libxl/gentypes.py: generate empty map for None field in keyed-union Wei Liu
2014-04-14 16:47   ` Ian Campbell
2014-04-14 16:53   ` Ian Campbell
2014-04-14 16:59     ` Wei Liu
2014-04-14 17:08       ` Ian Campbell
2014-04-14 17:11         ` Wei Liu
2014-04-16 16:30           ` Ian Campbell
2014-04-16 16:36             ` Wei Liu
2014-04-15 10:29         ` Ian Jackson
2014-04-15 10:32           ` Ian Campbell
2014-04-15 11:29             ` Ian Jackson
2014-04-10 15:26 ` [PATCH V2 4/4] libxl_types.idl: replace empty Struct with None for libxl_event Wei Liu
2014-04-14 16:49   ` Ian Campbell
2014-04-14 16:54     ` Wei Liu
2014-04-14 17:09       ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1397143594-15308-3-git-send-email-wei.liu2@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).