qapi: Use qapi_enum_parse() in input_type_enum()
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1503564371-26090-11-git-send-email-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
		
							parent
							
								
									9ae33079c2
								
							
						
					
					
						commit
						113e47ae6d
					
				@ -14,6 +14,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "qemu/osdep.h"
 | 
					#include "qemu/osdep.h"
 | 
				
			||||||
#include "qapi/error.h"
 | 
					#include "qapi/error.h"
 | 
				
			||||||
 | 
					#include "qapi/util.h"
 | 
				
			||||||
#include "qemu-common.h"
 | 
					#include "qemu-common.h"
 | 
				
			||||||
#include "qapi/qmp/qobject.h"
 | 
					#include "qapi/qmp/qobject.h"
 | 
				
			||||||
#include "qapi/qmp/qerror.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)
 | 
					                            const char *const strings[], Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Error *local_err = NULL;
 | 
					    Error *local_err = NULL;
 | 
				
			||||||
    int64_t value = 0;
 | 
					    int64_t value;
 | 
				
			||||||
    char *enum_str;
 | 
					    char *enum_str;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    visit_type_str(v, name, &enum_str, &local_err);
 | 
					    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;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while (strings[value] != NULL) {
 | 
					    value = qapi_enum_parse(strings, enum_str, -1, NULL);
 | 
				
			||||||
        if (strcmp(strings[value], enum_str) == 0) {
 | 
					    if (value < 0) {
 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        value++;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (strings[value] == NULL) {
 | 
					 | 
				
			||||||
        error_setg(errp, QERR_INVALID_PARAMETER, enum_str);
 | 
					        error_setg(errp, QERR_INVALID_PARAMETER, enum_str);
 | 
				
			||||||
        g_free(enum_str);
 | 
					        g_free(enum_str);
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user