qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v10 12/25] qapi-visit: Kill unused visit_end_union()


From: Eric Blake
Subject: [Qemu-devel] [PATCH v10 12/25] qapi-visit: Kill unused visit_end_union()
Date: Fri, 29 Jan 2016 06:48:48 -0700

The generated code can call visit_end_union() without having called
visit_start_union().  Example:

        if (!*obj) {
            goto out_obj;
        }
        visit_type_CpuInfoBase_fields(v, (CpuInfoBase **)obj, &err);
        if (err) {
            goto out_obj; // if we go from here...
        }
        if (!visit_start_union(v, !!(*obj)->u.data, &err) || err) {
            goto out_obj;
        }
        switch ((*obj)->arch) {
    [...]
        }
    out_obj:
        // ... then *obj is true, and ...
        error_propagate(errp, err);
        err = NULL;
        if (*obj) {
            // we end up here
            visit_end_union(v, !!(*obj)->u.data, &err);
        }
        error_propagate(errp, err);

Harmless only because no visitor implements end_union().  Clean it up
anyway, by deleting the function as useless.

Messed up since we have visit_end_union (commit cee2ded).

Signed-off-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>
[expand scope of patch to delete rather than repair]
Signed-off-by: Eric Blake <address@hidden>

---
v10: new patch; take Markus' commit message as a starting point (hence
his S-o-b), but rewrite the patch and claim ownership
---
 include/qapi/visitor.h      | 1 -
 include/qapi/visitor-impl.h | 1 -
 scripts/qapi-visit.py       | 5 -----
 qapi/qapi-visit-core.c      | 8 +-------
 4 files changed, 1 insertion(+), 14 deletions(-)

diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h
index a14a16d..83ac3ad 100644
--- a/include/qapi/visitor.h
+++ b/include/qapi/visitor.h
@@ -70,6 +70,5 @@ void visit_type_str(Visitor *v, char **obj, const char *name, 
Error **errp);
 void visit_type_number(Visitor *v, double *obj, const char *name, Error 
**errp);
 void visit_type_any(Visitor *v, QObject **obj, const char *name, Error **errp);
 bool visit_start_union(Visitor *v, bool data_present, Error **errp);
-void visit_end_union(Visitor *v, bool data_present, Error **errp);

 #endif
diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h
index 44a21b7..f314894 100644
--- a/include/qapi/visitor-impl.h
+++ b/include/qapi/visitor-impl.h
@@ -58,7 +58,6 @@ struct Visitor
     /* visit_type_size() falls back to (*type_uint64)() if type_size is unset 
*/
     void (*type_size)(Visitor *v, uint64_t *obj, const char *name, Error 
**errp);
     bool (*start_union)(Visitor *v, bool data_present, Error **errp);
-    void (*end_union)(Visitor *v, bool data_present, Error **errp);
 };

 void input_type_enum(Visitor *v, int *obj, const char * const strings[],
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index ec16e36..f98bb5f 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -320,11 +320,6 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, 
const char *name, Error
 out_obj:
     error_propagate(errp, err);
     err = NULL;
-    if (*obj) {
-        visit_end_union(v, !!(*obj)->u.data, &err);
-    }
-    error_propagate(errp, err);
-    err = NULL;
     visit_end_struct(v, &err);
 out:
     error_propagate(errp, err);
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 6d63e40..f96d82f 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -1,6 +1,7 @@
 /*
  * Core Definitions for QAPI Visitor Classes
  *
+ * Copyright (C) 2012-2016 Red Hat, Inc.
  * Copyright IBM, Corp. 2011
  *
  * Authors:
@@ -66,13 +67,6 @@ bool visit_start_union(Visitor *v, bool data_present, Error 
**errp)
     return true;
 }

-void visit_end_union(Visitor *v, bool data_present, Error **errp)
-{
-    if (v->end_union) {
-        v->end_union(v, data_present, errp);
-    }
-}
-
 bool visit_optional(Visitor *v, bool *present, const char *name)
 {
     if (v->optional) {
-- 
2.5.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]