]> git.ipfire.org Git - thirdparty/libvirt.git/commit
json: cope with older yajl semantics
authorEric Blake <eblake@redhat.com>
Mon, 22 Jun 2015 20:18:32 +0000 (14:18 -0600)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 25 Jun 2015 07:11:15 +0000 (09:11 +0200)
commitf2acaebd4085b663f7ab6566b22fe21e68f65ec9
treec8f01289a3dd9c0f6517003c9c1198647b5a83b9
parent39618d4088c69d06f666a1aa7639d36017e7ace9
json: cope with older yajl semantics

Commit ceb496e5 fails on RHEL 6, with yajl 1.0.7, because that
version of yajl returns yajl_status_insufficient_data when the
parser is waiting for the rest of a token (this enum value was
dropped in yajl 2, so we have to wrap it).  It also exposes a
problem where older yajl silently ignores trailing garbage after
a successful parse, so this patch works around that by changing
the testsuite.  Another more invasive patch can add tighter
semantics to json parsing, but this is sufficient for a minimal
clean backport.

While touching this, fix up our error message cleanup. Yajl
documents that error messages produced by yajl_get_error()
MUST be cleaned with yajl_free_error(); this is certainly
true if we were to pass non-NULL allocator callbacks during
yajl_alloc(), but probably harmless in our usage of passing
NULL.  But better safe than sorry.

* src/util/virjson.c (virJSONValueFromString): Allow different
error code.  Use canonical cleanup of error message.
(VIR_YAJL_STATUS_OK): New helper macro.
* tests/jsontest.c (mymain): Wrap text to avoid difference in
trailing garbage handling

Signed-off-by: Eric Blake <eblake@redhat.com>
src/util/virjson.c
tests/jsontest.c