On 05/18/2016 09:16 AM, Eric Blake wrote: >>> +static void json_output_type_any(Visitor *v, const char *name, QObject >>> **obj, >>> + Error **errp) >>> +{ >>> + JsonOutputVisitor *jov = to_jov(v); >>> + QString *str = qobject_to_json(*obj); >>> + assert(str); >> >> Can't happen. > > Can too. From tests/check-qobject-json.c: > > obj = QOBJECT(qstring_from_str(utf8_in)); > str = qobject_to_json(obj); > if (json_out) { > g_assert(str); > g_assert_cmpstr(qstring_get_str(str), ==, json_out); > } else { > g_assert(!str); > } > > where the failures occur when it is impossible to output proper UTF-8 > due to invalid encoding in a string.
Correction - that test has dead code, because: json_out = test_cases[i].json_out ?: test_cases[i].json_in; so you are right after all - we currently cannot fail on a conversion to JSON (although the result might not be valid JSON). At any rate, my conclusion remains: > Arguably, that case would be nicer > if it could set an Error* (and would make my argument for setting an > error on Inf/NaN for numbers also a bit more tenable), but that is > additional work that I haven't tackled yet. I'm trying to get the series > posted for another round of review, where I've done some major > reshuffling (such as doing the clone visitor first, not second, in the > series), so hopefully later today. > -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature