diff options
author | Markus Armbruster <armbru@redhat.com> | 2014-05-07 09:53:53 +0200 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2014-05-15 14:00:46 -0400 |
commit | cdaec3808e756fee3c4e17d0168ec6429eff0dbc (patch) | |
tree | 718af89969e579d18befe4b4c906f3ff9385176a | |
parent | 2ddb16a95f7d4edab4022ef4707d926c0c28db8d (diff) |
tests: Don't call visit_end_struct() after visit_start_struct() fails
When visit_start_struct() fails, visit_end_struct() must not be
called. Three out of four visit_type_TestStruct() call it anyway. As
far as I can tell, visit_start_struct() doesn't actually fail there.
Fix them anyway.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
-rw-r--r-- | tests/test-qmp-input-strict.c | 18 | ||||
-rw-r--r-- | tests/test-qmp-output-visitor.c | 18 | ||||
-rw-r--r-- | tests/test-visitor-serialization.c | 18 |
3 files changed, 39 insertions, 15 deletions
diff --git a/tests/test-qmp-input-strict.c b/tests/test-qmp-input-strict.c index 449d285e56..ec798c2acf 100644 --- a/tests/test-qmp-input-strict.c +++ b/tests/test-qmp-input-strict.c @@ -72,14 +72,22 @@ typedef struct TestStruct static void visit_type_TestStruct(Visitor *v, TestStruct **obj, const char *name, Error **errp) { + Error *err = NULL; + visit_start_struct(v, (void **)obj, "TestStruct", name, sizeof(TestStruct), - errp); + &err); + if (err) { + goto out; + } + + visit_type_int(v, &(*obj)->integer, "integer", &err); + visit_type_bool(v, &(*obj)->boolean, "boolean", &err); + visit_type_str(v, &(*obj)->string, "string", &err); - visit_type_int(v, &(*obj)->integer, "integer", errp); - visit_type_bool(v, &(*obj)->boolean, "boolean", errp); - visit_type_str(v, &(*obj)->string, "string", errp); + visit_end_struct(v, &err); - visit_end_struct(v, errp); +out: + error_propagate(errp, err); } static void test_validate_struct(TestInputVisitorData *data, diff --git a/tests/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c index 2580f3debf..dfd597cee1 100644 --- a/tests/test-qmp-output-visitor.c +++ b/tests/test-qmp-output-visitor.c @@ -176,14 +176,22 @@ typedef struct TestStruct static void visit_type_TestStruct(Visitor *v, TestStruct **obj, const char *name, Error **errp) { + Error *err = NULL; + visit_start_struct(v, (void **)obj, "TestStruct", name, sizeof(TestStruct), - errp); + &err); + if (err) { + goto out; + } + + visit_type_int(v, &(*obj)->integer, "integer", &err); + visit_type_bool(v, &(*obj)->boolean, "boolean", &err); + visit_type_str(v, &(*obj)->string, "string", &err); - visit_type_int(v, &(*obj)->integer, "integer", errp); - visit_type_bool(v, &(*obj)->boolean, "boolean", errp); - visit_type_str(v, &(*obj)->string, "string", errp); + visit_end_struct(v, &err); - visit_end_struct(v, errp); +out: + error_propagate(errp, err); } static void test_visitor_out_struct(TestOutputVisitorData *data, diff --git a/tests/test-visitor-serialization.c b/tests/test-visitor-serialization.c index 8166cf1b05..85170e5c49 100644 --- a/tests/test-visitor-serialization.c +++ b/tests/test-visitor-serialization.c @@ -195,13 +195,21 @@ typedef struct TestStruct static void visit_type_TestStruct(Visitor *v, TestStruct **obj, const char *name, Error **errp) { - visit_start_struct(v, (void **)obj, NULL, name, sizeof(TestStruct), errp); + Error *err= NULL; - visit_type_int(v, &(*obj)->integer, "integer", errp); - visit_type_bool(v, &(*obj)->boolean, "boolean", errp); - visit_type_str(v, &(*obj)->string, "string", errp); + visit_start_struct(v, (void **)obj, NULL, name, sizeof(TestStruct), &err); + if (err) { + goto out; + } + + visit_type_int(v, &(*obj)->integer, "integer", &err); + visit_type_bool(v, &(*obj)->boolean, "boolean", &err); + visit_type_str(v, &(*obj)->string, "string", &err); + + visit_end_struct(v, &err); - visit_end_struct(v, errp); +out: + error_propagate(errp, err); } static TestStruct *struct_create(void) |