]> xenbits.xensource.com Git - libvirt.git/commit
virjson: always raise vir error on append failures
authorEric Blake <eblake@redhat.com>
Fri, 25 Jan 2019 03:28:23 +0000 (21:28 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 25 Jan 2019 15:21:24 +0000 (09:21 -0600)
commit4ea5a41e16f76358d2bdce194dce0ba9bc5f0261
tree52c2c6750d186edcb6c56161eb9bcc13a841a402
parent2707d4f8bc7a65dea13b47422f0fe4c1309f9dc2
virjson: always raise vir error on append failures

A function that returns -1 for multiple possible failures, but only
raises a libvirt error for some of those failures, can be hard to
use correctly. Yet both of our JSON object/array appenders fall in
that pattern.  True, the silent errors represent coding bugs that
none of the callers should ever trigger, while the noisy errors
represent memory failures that can happen anywhere, so we happened
to never end up failing without an error. But it is better to
either use the _QUIET memory allocation variants, and make callers
decide to report failure; or make all failure paths noisy. This
patch takes the latter approach.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virjson.c