qapi: Simplify gen_visit_fields() error handling

Since we have consolidated all generated code to use 'err' as
the name of the local variable for error detection, we can
simplify the decision on whether to skip error detection (useful
for deallocation paths) to be a boolean.

Backports commit 18bdbc3ac8b477e160d56aa6ecd6942495ce44d0 from qemu
This commit is contained in:
Eric Blake 2018-02-19 18:43:38 -05:00 committed by Lioncash
parent 4ca10929a7
commit f371fa9105
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
5 changed files with 207 additions and 204 deletions

View file

@ -42,270 +42,270 @@ const char *const X86CPURegister32_lookup[] = {
void qapi_free_ErrorClassList(ErrorClassList *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_ErrorClassList(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_X86CPUFeatureWordInfo(X86CPUFeatureWordInfo *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_X86CPUFeatureWordInfo(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_X86CPUFeatureWordInfoList(X86CPUFeatureWordInfoList *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_X86CPUFeatureWordInfoList(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_X86CPURegister32List(X86CPURegister32List *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_X86CPURegister32List(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_anyList(anyList *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_anyList(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_boolList(boolList *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_boolList(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_int16List(int16List *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_int16List(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_int32List(int32List *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_int32List(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_int64List(int64List *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_int64List(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_int8List(int8List *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_int8List(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_intList(intList *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_intList(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_numberList(numberList *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_numberList(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_sizeList(sizeList *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_sizeList(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_strList(strList *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_strList(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_uint16List(uint16List *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_uint16List(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_uint32List(uint32List *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_uint32List(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_uint64List(uint64List *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_uint64List(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}
void qapi_free_uint8List(uint8List *obj)
{
QapiDeallocVisitor *md;
QapiDeallocVisitor *qdv;
Visitor *v;
if (!obj) {
return;
}
md = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(md);
qdv = qapi_dealloc_visitor_new();
v = qapi_dealloc_get_visitor(qdv);
visit_type_uint8List(v, &obj, NULL, NULL);
qapi_dealloc_visitor_cleanup(md);
qapi_dealloc_visitor_cleanup(qdv);
}

View file

@ -16,55 +16,58 @@
#include "qemu-common.h"
#include "qapi-visit.h"
void visit_type_ErrorClass(Visitor *m, ErrorClass *obj, const char *name, Error **errp)
void visit_type_ErrorClass(Visitor *v, ErrorClass *obj, const char *name, Error **errp)
{
visit_type_enum(m, (int *)obj, ErrorClass_lookup, "ErrorClass", name, errp);
visit_type_enum(v, (int *)obj, ErrorClass_lookup, "ErrorClass", name, errp);
}
void visit_type_ErrorClassList(Visitor *m, ErrorClassList **obj, const char *name, Error **errp)
void visit_type_ErrorClassList(Visitor *v, ErrorClassList **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
ErrorClassList *native_i = (ErrorClassList *)i;
visit_type_ErrorClass(m, &native_i->value, NULL, &err);
visit_type_ErrorClass(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
static void visit_type_X86CPUFeatureWordInfo_fields(Visitor *m, X86CPUFeatureWordInfo **obj, Error **errp)
static void visit_type_X86CPUFeatureWordInfo_fields(Visitor *v, X86CPUFeatureWordInfo **obj, Error **errp)
{
Error *err = NULL;
visit_type_int(m, &(*obj)->cpuid_input_eax, "cpuid-input-eax", &err);
visit_type_int(v, &(*obj)->cpuid_input_eax, "cpuid-input-eax", &err);
if (err) {
goto out;
}
visit_optional(m, &(*obj)->has_cpuid_input_ecx, "cpuid-input-ecx", &err);
if (!err && (*obj)->has_cpuid_input_ecx) {
visit_type_int(m, &(*obj)->cpuid_input_ecx, "cpuid-input-ecx", &err);
}
visit_optional(v, &(*obj)->has_cpuid_input_ecx, "cpuid-input-ecx", &err);
if (err) {
goto out;
}
visit_type_X86CPURegister32(m, &(*obj)->cpuid_register, "cpuid-register", &err);
if ((*obj)->has_cpuid_input_ecx) {
visit_type_int(v, &(*obj)->cpuid_input_ecx, "cpuid-input-ecx", &err);
if (err) {
goto out;
}
}
visit_type_X86CPURegister32(v, &(*obj)->cpuid_register, "cpuid-register", &err);
if (err) {
goto out;
}
visit_type_int(m, &(*obj)->features, "features", &err);
visit_type_int(v, &(*obj)->features, "features", &err);
if (err) {
goto out;
}
@ -73,406 +76,406 @@ out:
error_propagate(errp, err);
}
void visit_type_X86CPUFeatureWordInfo(Visitor *m, X86CPUFeatureWordInfo **obj, const char *name, Error **errp)
void visit_type_X86CPUFeatureWordInfo(Visitor *v, X86CPUFeatureWordInfo **obj, const char *name, Error **errp)
{
Error *err = NULL;
visit_start_struct(m, (void **)obj, "X86CPUFeatureWordInfo", name, sizeof(X86CPUFeatureWordInfo), &err);
visit_start_struct(v, (void **)obj, "X86CPUFeatureWordInfo", name, sizeof(X86CPUFeatureWordInfo), &err);
if (!err) {
if (*obj) {
visit_type_X86CPUFeatureWordInfo_fields(m, obj, errp);
visit_type_X86CPUFeatureWordInfo_fields(v, obj, errp);
}
visit_end_struct(m, &err);
visit_end_struct(v, &err);
}
error_propagate(errp, err);
}
void visit_type_X86CPUFeatureWordInfoList(Visitor *m, X86CPUFeatureWordInfoList **obj, const char *name, Error **errp)
void visit_type_X86CPUFeatureWordInfoList(Visitor *v, X86CPUFeatureWordInfoList **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
X86CPUFeatureWordInfoList *native_i = (X86CPUFeatureWordInfoList *)i;
visit_type_X86CPUFeatureWordInfo(m, &native_i->value, NULL, &err);
visit_type_X86CPUFeatureWordInfo(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_X86CPURegister32(Visitor *m, X86CPURegister32 *obj, const char *name, Error **errp)
void visit_type_X86CPURegister32(Visitor *v, X86CPURegister32 *obj, const char *name, Error **errp)
{
visit_type_enum(m, (int *)obj, X86CPURegister32_lookup, "X86CPURegister32", name, errp);
visit_type_enum(v, (int *)obj, X86CPURegister32_lookup, "X86CPURegister32", name, errp);
}
void visit_type_X86CPURegister32List(Visitor *m, X86CPURegister32List **obj, const char *name, Error **errp)
void visit_type_X86CPURegister32List(Visitor *v, X86CPURegister32List **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
X86CPURegister32List *native_i = (X86CPURegister32List *)i;
visit_type_X86CPURegister32(m, &native_i->value, NULL, &err);
visit_type_X86CPURegister32(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_anyList(Visitor *m, anyList **obj, const char *name, Error **errp)
void visit_type_anyList(Visitor *v, anyList **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
anyList *native_i = (anyList *)i;
visit_type_any(m, &native_i->value, NULL, &err);
visit_type_any(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_boolList(Visitor *m, boolList **obj, const char *name, Error **errp)
void visit_type_boolList(Visitor *v, boolList **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
boolList *native_i = (boolList *)i;
visit_type_bool(m, &native_i->value, NULL, &err);
visit_type_bool(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_int16List(Visitor *m, int16List **obj, const char *name, Error **errp)
void visit_type_int16List(Visitor *v, int16List **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
int16List *native_i = (int16List *)i;
visit_type_int16(m, &native_i->value, NULL, &err);
visit_type_int16(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_int32List(Visitor *m, int32List **obj, const char *name, Error **errp)
void visit_type_int32List(Visitor *v, int32List **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
int32List *native_i = (int32List *)i;
visit_type_int32(m, &native_i->value, NULL, &err);
visit_type_int32(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_int64List(Visitor *m, int64List **obj, const char *name, Error **errp)
void visit_type_int64List(Visitor *v, int64List **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
int64List *native_i = (int64List *)i;
visit_type_int64(m, &native_i->value, NULL, &err);
visit_type_int64(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_int8List(Visitor *m, int8List **obj, const char *name, Error **errp)
void visit_type_int8List(Visitor *v, int8List **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
int8List *native_i = (int8List *)i;
visit_type_int8(m, &native_i->value, NULL, &err);
visit_type_int8(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_intList(Visitor *m, intList **obj, const char *name, Error **errp)
void visit_type_intList(Visitor *v, intList **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
intList *native_i = (intList *)i;
visit_type_int(m, &native_i->value, NULL, &err);
visit_type_int(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_numberList(Visitor *m, numberList **obj, const char *name, Error **errp)
void visit_type_numberList(Visitor *v, numberList **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
numberList *native_i = (numberList *)i;
visit_type_number(m, &native_i->value, NULL, &err);
visit_type_number(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_sizeList(Visitor *m, sizeList **obj, const char *name, Error **errp)
void visit_type_sizeList(Visitor *v, sizeList **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
sizeList *native_i = (sizeList *)i;
visit_type_size(m, &native_i->value, NULL, &err);
visit_type_size(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_strList(Visitor *m, strList **obj, const char *name, Error **errp)
void visit_type_strList(Visitor *v, strList **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
strList *native_i = (strList *)i;
visit_type_str(m, &native_i->value, NULL, &err);
visit_type_str(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_uint16List(Visitor *m, uint16List **obj, const char *name, Error **errp)
void visit_type_uint16List(Visitor *v, uint16List **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
uint16List *native_i = (uint16List *)i;
visit_type_uint16(m, &native_i->value, NULL, &err);
visit_type_uint16(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_uint32List(Visitor *m, uint32List **obj, const char *name, Error **errp)
void visit_type_uint32List(Visitor *v, uint32List **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
uint32List *native_i = (uint32List *)i;
visit_type_uint32(m, &native_i->value, NULL, &err);
visit_type_uint32(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_uint64List(Visitor *m, uint64List **obj, const char *name, Error **errp)
void visit_type_uint64List(Visitor *v, uint64List **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
uint64List *native_i = (uint64List *)i;
visit_type_uint64(m, &native_i->value, NULL, &err);
visit_type_uint64(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}
void visit_type_uint8List(Visitor *m, uint8List **obj, const char *name, Error **errp)
void visit_type_uint8List(Visitor *v, uint8List **obj, const char *name, Error **errp)
{
Error *err = NULL;
GenericList *i, **prev;
visit_start_list(m, name, &err);
visit_start_list(v, name, &err);
if (err) {
goto out;
}
for (prev = (GenericList **)obj;
!err && (i = visit_next_list(m, prev)) != NULL;
!err && (i = visit_next_list(v, prev)) != NULL;
prev = &i) {
uint8List *native_i = (uint8List *)i;
visit_type_uint8(m, &native_i->value, NULL, &err);
visit_type_uint8(v, &native_i->value, NULL, &err);
}
error_propagate(errp, err);
err = NULL;
visit_end_list(m);
visit_end_list(v);
out:
error_propagate(errp, err);
}

View file

@ -23,28 +23,28 @@
#ifndef QAPI_VISIT_BUILTIN
#define QAPI_VISIT_BUILTIN
void visit_type_anyList(Visitor *m, anyList **obj, const char *name, Error **errp);
void visit_type_boolList(Visitor *m, boolList **obj, const char *name, Error **errp);
void visit_type_int16List(Visitor *m, int16List **obj, const char *name, Error **errp);
void visit_type_int32List(Visitor *m, int32List **obj, const char *name, Error **errp);
void visit_type_int64List(Visitor *m, int64List **obj, const char *name, Error **errp);
void visit_type_int8List(Visitor *m, int8List **obj, const char *name, Error **errp);
void visit_type_intList(Visitor *m, intList **obj, const char *name, Error **errp);
void visit_type_numberList(Visitor *m, numberList **obj, const char *name, Error **errp);
void visit_type_sizeList(Visitor *m, sizeList **obj, const char *name, Error **errp);
void visit_type_strList(Visitor *m, strList **obj, const char *name, Error **errp);
void visit_type_uint16List(Visitor *m, uint16List **obj, const char *name, Error **errp);
void visit_type_uint32List(Visitor *m, uint32List **obj, const char *name, Error **errp);
void visit_type_uint64List(Visitor *m, uint64List **obj, const char *name, Error **errp);
void visit_type_uint8List(Visitor *m, uint8List **obj, const char *name, Error **errp);
void visit_type_anyList(Visitor *v, anyList **obj, const char *name, Error **errp);
void visit_type_boolList(Visitor *v, boolList **obj, const char *name, Error **errp);
void visit_type_int16List(Visitor *v, int16List **obj, const char *name, Error **errp);
void visit_type_int32List(Visitor *v, int32List **obj, const char *name, Error **errp);
void visit_type_int64List(Visitor *v, int64List **obj, const char *name, Error **errp);
void visit_type_int8List(Visitor *v, int8List **obj, const char *name, Error **errp);
void visit_type_intList(Visitor *v, intList **obj, const char *name, Error **errp);
void visit_type_numberList(Visitor *v, numberList **obj, const char *name, Error **errp);
void visit_type_sizeList(Visitor *v, sizeList **obj, const char *name, Error **errp);
void visit_type_strList(Visitor *v, strList **obj, const char *name, Error **errp);
void visit_type_uint16List(Visitor *v, uint16List **obj, const char *name, Error **errp);
void visit_type_uint32List(Visitor *v, uint32List **obj, const char *name, Error **errp);
void visit_type_uint64List(Visitor *v, uint64List **obj, const char *name, Error **errp);
void visit_type_uint8List(Visitor *v, uint8List **obj, const char *name, Error **errp);
#endif /* QAPI_VISIT_BUILTIN */
void visit_type_ErrorClass(Visitor *m, ErrorClass *obj, const char *name, Error **errp);
void visit_type_ErrorClassList(Visitor *m, ErrorClassList **obj, const char *name, Error **errp);
void visit_type_X86CPUFeatureWordInfo(Visitor *m, X86CPUFeatureWordInfo **obj, const char *name, Error **errp);
void visit_type_X86CPUFeatureWordInfoList(Visitor *m, X86CPUFeatureWordInfoList **obj, const char *name, Error **errp);
void visit_type_X86CPURegister32(Visitor *m, X86CPURegister32 *obj, const char *name, Error **errp);
void visit_type_X86CPURegister32List(Visitor *m, X86CPURegister32List **obj, const char *name, Error **errp);
void visit_type_ErrorClass(Visitor *v, ErrorClass *obj, const char *name, Error **errp);
void visit_type_ErrorClassList(Visitor *v, ErrorClassList **obj, const char *name, Error **errp);
void visit_type_X86CPUFeatureWordInfo(Visitor *v, X86CPUFeatureWordInfo **obj, const char *name, Error **errp);
void visit_type_X86CPUFeatureWordInfoList(Visitor *v, X86CPUFeatureWordInfoList **obj, const char *name, Error **errp);
void visit_type_X86CPURegister32(Visitor *v, X86CPURegister32 *obj, const char *name, Error **errp);
void visit_type_X86CPURegister32List(Visitor *v, X86CPURegister32List **obj, const char *name, Error **errp);
#endif

View file

@ -288,7 +288,7 @@ c_comment = '''
* Anthony Liguori <aliguori@us.ibm.com>
* Michael Roth <mdroth@linux.vnet.ibm.com>
*
* This work is lifcensed under the terms of the GNU LGPL, version 2.1 or later.
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
* See the COPYING.LIB file in the top-level directory.
*
*/

View file

@ -1532,23 +1532,23 @@ def gen_params(arg_type, extra):
return ret
def gen_err_check(err='err', label='out'):
if not err:
def gen_err_check(label='out', skiperr=False):
if skiperr:
return ''
return mcgen('''
if (%(err)s) {
if (err) {
goto %(label)s;
}
''',
err=err, label=label)
label=label)
def gen_visit_fields(members, prefix='', need_cast=False, errarg='err'):
def gen_visit_fields(members, prefix='', need_cast=False, skiperr=False):
ret = ''
if errarg:
errparg = '&' + errarg
else:
if skiperr:
errparg = 'NULL'
else:
errparg = '&err'
for memb in members:
if memb.optional:
@ -1557,7 +1557,7 @@ def gen_visit_fields(members, prefix='', need_cast=False, errarg='err'):
''',
prefix=prefix, c_name=c_name(memb.name),
name=memb.name, errp=errparg)
ret += gen_err_check(err=errarg)
ret += gen_err_check(skiperr=skiperr)
ret += mcgen('''
if (%(prefix)shas_%(c_name)s) {
''',
@ -1576,7 +1576,7 @@ def gen_visit_fields(members, prefix='', need_cast=False, errarg='err'):
c_type=memb.type.c_name(), prefix=prefix, cast=cast,
c_name=c_name(memb.name), name=memb.name,
errp=errparg)
ret += gen_err_check(err=errarg)
ret += gen_err_check(skiperr=skiperr)
if memb.optional:
pop_indent()