qapi-visit: Kill unused visit_end_union()

The generated code can call visit_end_union() without having called
visit_start_union(). Example:

if (!*obj) {
goto out_obj;
}
visit_type_CpuInfoBase_fields(v, (CpuInfoBase **)obj, &err);
if (err) {
goto out_obj; // if we go from here...
}
if (!visit_start_union(v, !!(*obj)->u.data, &err) || err) {
goto out_obj;
}
switch ((*obj)->arch) {
[...]
}
out_obj:
// ... then *obj is true, and ...
error_propagate(errp, err);
err = NULL;
if (*obj) {
// we end up here
visit_end_union(v, !!(*obj)->u.data, &err);
}
error_propagate(errp, err);

Harmless only because no visitor implements end_union(). Clean it up
anyway, by deleting the function as useless.

Messed up since we have visit_end_union (commit cee2ded).

Backports commit 7c91aabd8964cfdf637f302c579c95401f21ce92 from qemu
This commit is contained in:
Eric Blake 2018-02-19 22:21:33 -05:00 committed by Lioncash
parent 264748ad06
commit 7e83274012
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
5 changed files with 24 additions and 24 deletions

View file

@ -35,12 +35,18 @@ void visit_type_DummyForceArrays(Visitor *v, DummyForceArrays **obj, const char
visit_start_struct(v, (void **)obj, "DummyForceArrays", name, sizeof(DummyForceArrays), &err); visit_start_struct(v, (void **)obj, "DummyForceArrays", name, sizeof(DummyForceArrays), &err);
if (!err) { if (err) {
if (*obj) { goto out;
visit_type_DummyForceArrays_fields(v, obj, errp);
}
visit_end_struct(v, &err);
} }
if (!*obj) {
goto out_obj;
}
visit_type_DummyForceArrays_fields(v, obj, &err);
error_propagate(errp, err);
err = NULL;
out_obj:
visit_end_struct(v, &err);
out:
error_propagate(errp, err); error_propagate(errp, err);
} }
@ -87,12 +93,18 @@ void visit_type_X86CPUFeatureWordInfo(Visitor *v, X86CPUFeatureWordInfo **obj, c
visit_start_struct(v, (void **)obj, "X86CPUFeatureWordInfo", name, sizeof(X86CPUFeatureWordInfo), &err); visit_start_struct(v, (void **)obj, "X86CPUFeatureWordInfo", name, sizeof(X86CPUFeatureWordInfo), &err);
if (!err) { if (err) {
if (*obj) { goto out;
visit_type_X86CPUFeatureWordInfo_fields(v, obj, errp);
}
visit_end_struct(v, &err);
} }
if (!*obj) {
goto out_obj;
}
visit_type_X86CPUFeatureWordInfo_fields(v, obj, &err);
error_propagate(errp, err);
err = NULL;
out_obj:
visit_end_struct(v, &err);
out:
error_propagate(errp, err); error_propagate(errp, err);
} }

View file

@ -62,7 +62,6 @@ struct Visitor
void (*type_int16)(Visitor *v, int16_t *obj, const char *name, Error **errp); void (*type_int16)(Visitor *v, int16_t *obj, const char *name, Error **errp);
void (*type_int32)(Visitor *v, int32_t *obj, const char *name, Error **errp); void (*type_int32)(Visitor *v, int32_t *obj, const char *name, Error **errp);
bool (*start_union)(Visitor *v, bool data_present, Error **errp); bool (*start_union)(Visitor *v, bool data_present, Error **errp);
void (*end_union)(Visitor *v, bool data_present, Error **errp);
}; };
void input_type_enum(Visitor *v, int *obj, const char * const strings[], void input_type_enum(Visitor *v, int *obj, const char * const strings[],

View file

@ -70,6 +70,5 @@ void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp);
void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp); void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp);
void visit_type_any(Visitor *v, QObject **obj, const char *name, Error **errp); void visit_type_any(Visitor *v, QObject **obj, const char *name, Error **errp);
bool visit_start_union(Visitor *v, bool data_present, Error **errp); bool visit_start_union(Visitor *v, bool data_present, Error **errp);
void visit_end_union(Visitor *v, bool data_present, Error **errp);
#endif #endif

View file

@ -1,8 +1,10 @@
/* /*
* Core Definitions for QAPI Visitor Classes * Core Definitions for QAPI Visitor Classes
* *
* Copyright (C) 2012-2016 Red Hat, Inc.
* Copyright IBM, Corp. 2011 * Copyright IBM, Corp. 2011
* *
*
* Authors: * Authors:
* Anthony Liguori <aliguori@us.ibm.com> * Anthony Liguori <aliguori@us.ibm.com>
* *
@ -67,13 +69,6 @@ bool visit_start_union(Visitor *v, bool data_present, Error **errp)
return true; return true;
} }
void visit_end_union(Visitor *v, bool data_present, Error **errp)
{
if (v->end_union) {
v->end_union(v, data_present, errp);
}
}
bool visit_optional(Visitor *v, bool *present, const char *name) bool visit_optional(Visitor *v, bool *present, const char *name)
{ {
if (v->optional) { if (v->optional) {

View file

@ -316,11 +316,6 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error
abort(); abort();
} }
out_obj: out_obj:
error_propagate(errp, err);
err = NULL;
if (*obj) {
visit_end_union(v, !!(*obj)->u.data, &err);
}
error_propagate(errp, err); error_propagate(errp, err);
err = NULL; err = NULL;
visit_end_struct(v, &err); visit_end_struct(v, &err);