On Thu, Aug 24, 2017 at 10:46 AM, Markus Armbruster <arm...@redhat.com> wrote: > Signed-off-by: Markus Armbruster <arm...@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com> > --- > qapi/qapi-visit-core.c | 13 ++++--------- > 1 file changed, 4 insertions(+), 9 deletions(-) > > diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c > index ed6d2af..ec83ff6 100644 > --- a/qapi/qapi-visit-core.c > +++ b/qapi/qapi-visit-core.c > @@ -14,6 +14,7 @@ > > #include "qemu/osdep.h" > #include "qapi/error.h" > +#include "qapi/util.h" > #include "qemu-common.h" > #include "qapi/qmp/qobject.h" > #include "qapi/qmp/qerror.h" > @@ -353,7 +354,7 @@ static void input_type_enum(Visitor *v, const char *name, > int *obj, > const char *const strings[], Error **errp) > { > Error *local_err = NULL; > - int64_t value = 0; > + int64_t value; > char *enum_str; > > visit_type_str(v, name, &enum_str, &local_err); > @@ -362,14 +363,8 @@ static void input_type_enum(Visitor *v, const char > *name, int *obj, > return; > } > > - while (strings[value] != NULL) { > - if (strcmp(strings[value], enum_str) == 0) { > - break; > - } > - value++; > - } > - > - if (strings[value] == NULL) { > + value = qapi_enum_parse(strings, enum_str, -1, NULL); > + if (value < 0) { > error_setg(errp, QERR_INVALID_PARAMETER, enum_str); > g_free(enum_str); > return; > -- > 2.7.5 > > -- Marc-André Lureau