From 1f54314cbbac0e45cbf2ce66cc7f60ead852c049 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 19 Feb 2018 23:42:59 -0500 Subject: [PATCH] qapi: Drop unused 'kind' for struct/enum visit visit_start_struct() and visit_type_enum() had a 'kind' argument that was usually set to either the stringized version of the corresponding qapi type name, or to NULL (although some clients didn't even get that right). But nothing ever used the argument. It's even hard to argue that it would be useful in a debugger, as a stack backtrace also tells which type is being visited. Therefore, drop the 'kind' argument as dead. Backports commit 337283dffbb5ad5860ed00408a5fd0665c21be07 from qemu --- msvc/unicorn/qapi-visit.c | 10 +++++----- qemu/include/qapi/visitor-impl.h | 11 ++++------- qemu/include/qapi/visitor.h | 5 ++--- qemu/qapi/qapi-dealloc-visitor.c | 6 ++---- qemu/qapi/qapi-visit-core.c | 15 ++++++--------- qemu/qapi/qmp-input-visitor.c | 2 +- qemu/qapi/qmp-output-visitor.c | 3 +-- qemu/scripts/qapi-event.py | 2 +- qemu/scripts/qapi-visit.py | 12 ++++++------ 9 files changed, 28 insertions(+), 38 deletions(-) diff --git a/msvc/unicorn/qapi-visit.c b/msvc/unicorn/qapi-visit.c index 003968a8..e2a7e1c1 100644 --- a/msvc/unicorn/qapi-visit.c +++ b/msvc/unicorn/qapi-visit.c @@ -33,7 +33,7 @@ void visit_type_DummyForceArrays(Visitor *v, const char *name, DummyForceArrays { Error *err = NULL; - visit_start_struct(v, name, (void **)obj, "DummyForceArrays", sizeof(DummyForceArrays), &err); + visit_start_struct(v, name, (void **)obj, sizeof(DummyForceArrays), &err); if (err) { goto out; @@ -53,14 +53,14 @@ out: void visit_type_QType(Visitor *v, const char *name, QType *obj, Error **errp) { int value = *obj; - visit_type_enum(v, name, &value, QType_lookup, "QType", errp); + visit_type_enum(v, name, &value, QType_lookup, errp); *obj = value; } void visit_type_QapiErrorClass(Visitor *v, const char *name, QapiErrorClass *obj, Error **errp) { int value = *obj; - visit_type_enum(v, name, &value, QapiErrorClass_lookup, "QapiErrorClass", errp); + visit_type_enum(v, name, &value, QapiErrorClass_lookup, errp); *obj = value; } @@ -95,7 +95,7 @@ void visit_type_X86CPUFeatureWordInfo(Visitor *v, const char *name, X86CPUFeatur { Error *err = NULL; - visit_start_struct(v, name, (void **)obj, "X86CPUFeatureWordInfo", sizeof(X86CPUFeatureWordInfo), &err); + visit_start_struct(v, name, (void **)obj, sizeof(X86CPUFeatureWordInfo), &err); if (err) { goto out; @@ -139,7 +139,7 @@ out: void visit_type_X86CPURegister32(Visitor *v, const char *name, X86CPURegister32 *obj, Error **errp) { int value = *obj; - visit_type_enum(v, name, &value, X86CPURegister32_lookup, "X86CPURegister32", errp); + visit_type_enum(v, name, &value, X86CPURegister32_lookup, errp); *obj = value; } diff --git a/qemu/include/qapi/visitor-impl.h b/qemu/include/qapi/visitor-impl.h index df54cac6..f0a74c3e 100644 --- a/qemu/include/qapi/visitor-impl.h +++ b/qemu/include/qapi/visitor-impl.h @@ -19,7 +19,7 @@ struct Visitor { /* Must be set */ void (*start_struct)(Visitor *v, const char *name, void **obj, - const char *kind, size_t size, Error **errp); + size_t size, Error **errp); void (*end_struct)(Visitor *v, Error **errp); void (*start_implicit_struct)(Visitor *v, void **obj, size_t size, @@ -31,8 +31,7 @@ struct Visitor void (*end_list)(Visitor *v); void (*type_enum)(Visitor *v, const char *name, int *obj, - const char *const strings[], const char *kind, - Error **errp); + const char *const strings[], Error **errp); /* May be NULL; only needed for input visitors. */ void (*get_next_type)(Visitor *v, const char *name, QType *type, bool promote_int, Error **errp); @@ -60,10 +59,8 @@ struct Visitor }; void input_type_enum(Visitor *v, const char *name, int *obj, - const char * const strings[], - const char *kind, Error **errp); + const char *const strings[], Error **errp); void output_type_enum(Visitor *v, const char *name, int *obj, - const char * const strings[], - const char *kind, Error **errp); + const char *const strings[], Error **errp); #endif diff --git a/qemu/include/qapi/visitor.h b/qemu/include/qapi/visitor.h index b3a2541e..2c48e2e0 100644 --- a/qemu/include/qapi/visitor.h +++ b/qemu/include/qapi/visitor.h @@ -28,7 +28,7 @@ typedef struct GenericList } GenericList; void visit_start_struct(Visitor *v, const char *name, void **obj, - const char *kind, size_t size, Error **errp); + size_t size, Error **errp); void visit_end_struct(Visitor *v, Error **errp); void visit_start_implicit_struct(Visitor *v, void **obj, size_t size, Error **errp); @@ -54,8 +54,7 @@ bool visit_optional(Visitor *v, const char *name, bool *present); void visit_get_next_type(Visitor *v, const char *name, QType *type, bool promote_int, Error **errp); void visit_type_enum(Visitor *v, const char *name, int *obj, - const char *const strings[], const char *kind, - Error **errp); + const char *const strings[], Error **errp); void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp); void visit_type_uint8(Visitor *v, const char *name, uint8_t *obj, Error **errp); diff --git a/qemu/qapi/qapi-dealloc-visitor.c b/qemu/qapi/qapi-dealloc-visitor.c index 4cf09059..166f5ec1 100644 --- a/qemu/qapi/qapi-dealloc-visitor.c +++ b/qemu/qapi/qapi-dealloc-visitor.c @@ -61,8 +61,7 @@ static void *qapi_dealloc_pop(QapiDeallocVisitor *qov) } static void qapi_dealloc_start_struct(Visitor *v, const char *name, void **obj, - const char *kind, size_t unused, - Error **errp) + size_t unused, Error **errp) { QapiDeallocVisitor *qov = to_qov(v); qapi_dealloc_push(qov, obj); @@ -170,8 +169,7 @@ static void qapi_dealloc_type_size(Visitor *v, const char *name, uint64_t *obj, } static void qapi_dealloc_type_enum(Visitor *v, const char *name, int *obj, - const char * const strings[], - const char *kind, Error **errp) + const char * const strings[], Error **errp) { } diff --git a/qemu/qapi/qapi-visit-core.c b/qemu/qapi/qapi-visit-core.c index 2dada916..640d9f03 100644 --- a/qemu/qapi/qapi-visit-core.c +++ b/qemu/qapi/qapi-visit-core.c @@ -21,9 +21,9 @@ #include "qapi/visitor-impl.h" void visit_start_struct(Visitor *v, const char *name, void **obj, - const char *kind, size_t size, Error **errp) + size_t size, Error **errp) { - v->start_struct(v, name, obj, kind, size, errp); + v->start_struct(v, name, obj, size, errp); } void visit_end_struct(Visitor *v, Error **errp) @@ -86,10 +86,9 @@ void visit_get_next_type(Visitor *v, const char *name, QType *type, } void visit_type_enum(Visitor *v, const char *name, int *obj, - const char *const strings[], const char *kind, - Error **errp) + const char *const strings[], Error **errp) { - v->type_enum(v, name, obj, strings, kind, errp); + v->type_enum(v, name, obj, strings, errp); } void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp) @@ -220,8 +219,7 @@ void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp) } void output_type_enum(Visitor *v, const char *name, int *obj, - const char *const strings[], const char *kind, - Error **errp) + const char *const strings[], Error **errp) { int i = 0; int value = *obj; @@ -239,8 +237,7 @@ void output_type_enum(Visitor *v, const char *name, int *obj, } void input_type_enum(Visitor *v, const char *name, int *obj, - const char *const strings[], const char *kind, - Error **errp) + const char *const strings[], Error **errp) { Error *local_err = NULL; int64_t value = 0; diff --git a/qemu/qapi/qmp-input-visitor.c b/qemu/qapi/qmp-input-visitor.c index c811831e..15fa3f62 100644 --- a/qemu/qapi/qmp-input-visitor.c +++ b/qemu/qapi/qmp-input-visitor.c @@ -116,7 +116,7 @@ static void qmp_input_pop(QmpInputVisitor *qiv, Error **errp) } static void qmp_input_start_struct(Visitor *v, const char *name, void **obj, - const char *kind, size_t size, Error **errp) + size_t size, Error **errp) { QmpInputVisitor *qiv = to_qiv(v); QObject *qobj = qmp_input_get_object(qiv, name, true); diff --git a/qemu/qapi/qmp-output-visitor.c b/qemu/qapi/qmp-output-visitor.c index 147343fe..e49b92cd 100644 --- a/qemu/qapi/qmp-output-visitor.c +++ b/qemu/qapi/qmp-output-visitor.c @@ -109,8 +109,7 @@ static void qmp_output_add_obj(QmpOutputVisitor *qov, const char *name, } static void qmp_output_start_struct(Visitor *v, const char *name, void **obj, - const char *kind, size_t unused, - Error **errp) + size_t unused, Error **errp) { QmpOutputVisitor *qov = to_qov(v); QDict *dict = qdict_new(); diff --git a/qemu/scripts/qapi-event.py b/qemu/scripts/qapi-event.py index 4900be9a..22cbf7e6 100644 --- a/qemu/scripts/qapi-event.py +++ b/qemu/scripts/qapi-event.py @@ -63,7 +63,7 @@ def gen_event_send(name, arg_type): v = qmp_output_get_visitor(qov); - visit_start_struct(v, "%(name)s", NULL, NULL, 0, &err); + visit_start_struct(v, "%(name)s", NULL, 0, &err); ''', name=name) ret += gen_err_check() diff --git a/qemu/scripts/qapi-visit.py b/qemu/scripts/qapi-visit.py index 4134902d..4d73e02f 100644 --- a/qemu/scripts/qapi-visit.py +++ b/qemu/scripts/qapi-visit.py @@ -119,7 +119,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error { Error *err = NULL; - visit_start_struct(v, name, (void **)obj, "%(name)s", sizeof(%(c_name)s), &err); + visit_start_struct(v, name, (void **)obj, sizeof(%(c_name)s), &err); if (err) { goto out; @@ -136,7 +136,7 @@ out: error_propagate(errp, err); } ''', - name=name, c_name=c_name(name)) + c_name=c_name(name)) return ret @@ -180,11 +180,11 @@ def gen_visit_enum(name): void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s *obj, Error **errp) { int value = *obj; - visit_type_enum(v, name, &value, %(c_name)s_lookup, "%(name)s", errp); + visit_type_enum(v, name, &value, %(c_name)s_lookup, errp); *obj = value; } ''', - c_name=c_name(name), name=name) + c_name=c_name(name)) def gen_visit_alternate(name, variants): @@ -256,7 +256,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error { Error *err = NULL; - visit_start_struct(v, name, (void **)obj, "%(name)s", sizeof(%(c_name)s), &err); + visit_start_struct(v, name, (void **)obj, sizeof(%(c_name)s), &err); if (err) { goto out; } @@ -264,7 +264,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error goto out_obj; } ''', - c_name=c_name(name), name=name) + c_name=c_name(name)) if base: ret += mcgen('''