mirror of
https://github.com/qemu/qemu.git
synced 2024-11-29 23:03:41 +08:00
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>
This commit is contained in:
parent
2ddb16a95f
commit
cdaec3808e
@ -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", errp);
|
||||
visit_type_bool(v, &(*obj)->boolean, "boolean", errp);
|
||||
visit_type_str(v, &(*obj)->string, "string", errp);
|
||||
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, errp);
|
||||
visit_end_struct(v, &err);
|
||||
|
||||
out:
|
||||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
static void test_validate_struct(TestInputVisitorData *data,
|
||||
|
@ -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", errp);
|
||||
visit_type_bool(v, &(*obj)->boolean, "boolean", errp);
|
||||
visit_type_str(v, &(*obj)->string, "string", errp);
|
||||
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, errp);
|
||||
visit_end_struct(v, &err);
|
||||
|
||||
out:
|
||||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
static void test_visitor_out_struct(TestOutputVisitorData *data,
|
||||
|
@ -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_end_struct(v, errp);
|
||||
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);
|
||||
|
||||
out:
|
||||
error_propagate(errp, err);
|
||||
}
|
||||
|
||||
static TestStruct *struct_create(void)
|
||||
|
Loading…
Reference in New Issue
Block a user