diff --git a/msvc/unicorn/qapi-visit.c b/msvc/unicorn/qapi-visit.c index f5ed07da..cceef9a7 100644 --- a/msvc/unicorn/qapi-visit.c +++ b/msvc/unicorn/qapi-visit.c @@ -52,12 +52,16 @@ out: void visit_type_QType(Visitor *v, QType *obj, const char *name, Error **errp) { - visit_type_enum(v, (int *)obj, QType_lookup, "QType", name, errp); + int value = *obj; + visit_type_enum(v, &value, QType_lookup, "QType", name, errp); + *obj = value; } void visit_type_QapiErrorClass(Visitor *v, QapiErrorClass *obj, const char *name, Error **errp) { - visit_type_enum(v, (int *)obj, QapiErrorClass_lookup, "QapiErrorClass", name, errp); + int value = *obj; + visit_type_enum(v, &value, QapiErrorClass_lookup, "QapiErrorClass", name, errp); + *obj = value; } static void visit_type_X86CPUFeatureWordInfo_fields(Visitor *v, X86CPUFeatureWordInfo **obj, Error **errp) @@ -134,7 +138,9 @@ out: void visit_type_X86CPURegister32(Visitor *v, X86CPURegister32 *obj, const char *name, Error **errp) { - visit_type_enum(v, (int *)obj, X86CPURegister32_lookup, "X86CPURegister32", name, errp); + int value = *obj; + visit_type_enum(v, &value, X86CPURegister32_lookup, "X86CPURegister32", name, errp); + *obj = value; } void visit_type_anyList(Visitor *v, anyList **obj, const char *name, Error **errp) diff --git a/qemu/scripts/qapi-visit.py b/qemu/scripts/qapi-visit.py index 65a8cc92..3a1e79fd 100644 --- a/qemu/scripts/qapi-visit.py +++ b/qemu/scripts/qapi-visit.py @@ -175,12 +175,13 @@ out: def gen_visit_enum(name): - # FIXME cast from enum *obj to int * invalidly assumes enum is int return mcgen(''' void visit_type_%(c_name)s(Visitor *v, %(c_name)s *obj, const char *name, Error **errp) { - visit_type_enum(v, (int *)obj, %(c_name)s_lookup, "%(name)s", name, errp); + int value = *obj; + visit_type_enum(v, &value, %(c_name)s_lookup, "%(name)s", name, errp); + *obj = value; } ''', c_name=c_name(name), name=name)