libxl_json: fix JSON parser debug code

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>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
This commit is contained in:
Wei Liu authored and Ian Campbell committed 2014-04-16 17:06:41 +01:00
1 parent 172c47d1c8
commit b955e8c5b7
1 file changed
+13 -4
+13 -4
View File
@@ -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); \
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.