aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-qmp-input-strict.c10
-rw-r--r--tests/test-qmp-input-visitor.c26
-rw-r--r--tests/test-qmp-output-visitor.c10
-rw-r--r--tests/test-visitor-serialization.c12
4 files changed, 45 insertions, 13 deletions
diff --git a/tests/test-qmp-input-strict.c b/tests/test-qmp-input-strict.c
index ec798c2acf..0f770034b1 100644
--- a/tests/test-qmp-input-strict.c
+++ b/tests/test-qmp-input-strict.c
@@ -81,11 +81,19 @@ static void visit_type_TestStruct(Visitor *v, TestStruct **obj,
}
visit_type_int(v, &(*obj)->integer, "integer", &err);
+ if (err) {
+ goto out_end;
+ }
visit_type_bool(v, &(*obj)->boolean, "boolean", &err);
+ if (err) {
+ goto out_end;
+ }
visit_type_str(v, &(*obj)->string, "string", &err);
+out_end:
+ error_propagate(errp, err);
+ err = NULL;
visit_end_struct(v, &err);
-
out:
error_propagate(errp, err);
}
diff --git a/tests/test-qmp-input-visitor.c b/tests/test-qmp-input-visitor.c
index a58a3e6fdb..1c8e87295c 100644
--- a/tests/test-qmp-input-visitor.c
+++ b/tests/test-qmp-input-visitor.c
@@ -199,16 +199,24 @@ static void visit_type_TestStruct(Visitor *v, TestStruct **obj,
visit_start_struct(v, (void **)obj, "TestStruct", name, sizeof(TestStruct),
&err);
- if (!err) {
- visit_type_int(v, &(*obj)->integer, "integer", &err);
- visit_type_bool(v, &(*obj)->boolean, "boolean", &err);
- visit_type_str(v, &(*obj)->string, "string", &err);
-
- /* Always call end_struct if start_struct succeeded. */
- error_propagate(errp, err);
- err = NULL;
- visit_end_struct(v, &err);
+ if (err) {
+ goto out;
}
+ visit_type_int(v, &(*obj)->integer, "integer", &err);
+ if (err) {
+ goto out_end;
+ }
+ visit_type_bool(v, &(*obj)->boolean, "boolean", &err);
+ if (err) {
+ goto out_end;
+ }
+ visit_type_str(v, &(*obj)->string, "string", &err);
+
+out_end:
+ error_propagate(errp, err);
+ err = NULL;
+ visit_end_struct(v, &err);
+out:
error_propagate(errp, err);
}
diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c
index dfd597cee1..9c154581d7 100644
--- a/tests/test-qmp-output-visitor.c
+++ b/tests/test-qmp-output-visitor.c
@@ -185,11 +185,19 @@ static void visit_type_TestStruct(Visitor *v, TestStruct **obj,
}
visit_type_int(v, &(*obj)->integer, "integer", &err);
+ if (err) {
+ goto out_end;
+ }
visit_type_bool(v, &(*obj)->boolean, "boolean", &err);
+ if (err) {
+ goto out_end;
+ }
visit_type_str(v, &(*obj)->string, "string", &err);
+out_end:
+ error_propagate(errp, err);
+ err = NULL;
visit_end_struct(v, &err);
-
out:
error_propagate(errp, err);
}
diff --git a/tests/test-visitor-serialization.c b/tests/test-visitor-serialization.c
index 85170e5c49..74d6481992 100644
--- a/tests/test-visitor-serialization.c
+++ b/tests/test-visitor-serialization.c
@@ -195,7 +195,7 @@ typedef struct TestStruct
static void visit_type_TestStruct(Visitor *v, TestStruct **obj,
const char *name, Error **errp)
{
- Error *err= NULL;
+ Error *err = NULL;
visit_start_struct(v, (void **)obj, NULL, name, sizeof(TestStruct), &err);
if (err) {
@@ -203,11 +203,19 @@ static void visit_type_TestStruct(Visitor *v, TestStruct **obj,
}
visit_type_int(v, &(*obj)->integer, "integer", &err);
+ if (err) {
+ goto out_end;
+ }
visit_type_bool(v, &(*obj)->boolean, "boolean", &err);
+ if (err) {
+ goto out_end;
+ }
visit_type_str(v, &(*obj)->string, "string", &err);
+out_end:
+ error_propagate(errp, err);
+ err = NULL;
visit_end_struct(v, &err);
-
out:
error_propagate(errp, err);
}