aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block.c5
-rw-r--r--qapi/qobject-input-visitor.c5
-rw-r--r--qobject/qjson.c4
-rw-r--r--tests/check-qjson.c12
4 files changed, 14 insertions, 12 deletions
diff --git a/block.c b/block.c
index 6161dbe3eb..0dbb1fcc7b 100644
--- a/block.c
+++ b/block.c
@@ -1478,11 +1478,6 @@ static QDict *parse_json_filename(const char *filename, Error **errp)
options_obj = qobject_from_json(filename, errp);
if (!options_obj) {
- /* Work around qobject_from_json() lossage TODO fix that */
- if (errp && !*errp) {
- error_setg(errp, "Could not parse the JSON options");
- return NULL;
- }
error_prepend(errp, "Could not parse the JSON options: ");
return NULL;
}
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index da57f4cc24..3e88b27f9e 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -725,11 +725,6 @@ Visitor *qobject_input_visitor_new_str(const char *str,
if (is_json) {
obj = qobject_from_json(str, errp);
if (!obj) {
- /* Work around qobject_from_json() lossage TODO fix that */
- if (errp && !*errp) {
- error_setg(errp, "JSON parse error");
- return NULL;
- }
return NULL;
}
args = qobject_to(QDict, obj);
diff --git a/qobject/qjson.c b/qobject/qjson.c
index 7f69036487..b9ccae2c2a 100644
--- a/qobject/qjson.c
+++ b/qobject/qjson.c
@@ -70,6 +70,10 @@ static QObject *qobject_from_jsonv(const char *string, va_list *ap,
json_message_parser_flush(&state.parser);
json_message_parser_destroy(&state.parser);
+ if (!state.result && !state.err) {
+ error_setg(&state.err, "Expecting a JSON value");
+ }
+
error_propagate(errp, state.err);
return state.result;
}
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 0ca4b3c823..936258ddd4 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -1291,13 +1291,21 @@ static void simple_interpolation(void)
static void empty_input(void)
{
- QObject *obj = qobject_from_json("", &error_abort);
+ Error *err = NULL;
+ QObject *obj;
+
+ obj = qobject_from_json("", &err);
+ error_free_or_abort(&err);
g_assert(obj == NULL);
}
static void blank_input(void)
{
- QObject *obj = qobject_from_json("\n ", &error_abort);
+ Error *err = NULL;
+ QObject *obj;
+
+ obj = qobject_from_json("\n ", &err);
+ error_free_or_abort(&err);
g_assert(obj == NULL);
}