• E
    qapi-visit: Less indirection in visit_type_Foo_fields() · 65551903
    Eric Blake 提交于
    We were passing 'Foo **obj' to the internal helper function, but
    all uses within the helper were via reads of '*obj'.  Refactor
    things to pass one less level of indirection, by having the
    callers dereference before calling.
    
    For an example of the generated code change:
    
    |-static void visit_type_BalloonInfo_fields(Visitor *v, BalloonInfo **obj, Error **errp)
    |+static void visit_type_BalloonInfo_fields(Visitor *v, BalloonInfo *obj, Error **errp)
    | {
    |     Error *err = NULL;
    |
    |-    visit_type_int(v, "actual", &(*obj)->actual, &err);
    |+    visit_type_int(v, "actual", &obj->actual, &err);
    |     error_propagate(errp, err);
    | }
    |
    |@@ -261,7 +261,7 @@ void visit_type_BalloonInfo(Visitor *v,
    |     if (!*obj) {
    |         goto out_obj;
    |     }
    |-    visit_type_BalloonInfo_fields(v, obj, &err);
    |+    visit_type_BalloonInfo_fields(v, *obj, &err);
    | out_obj:
    
    The refactoring will also make it easier to reuse the helpers in
    a future patch when implicit structs are stored directly in the
    parent struct rather than boxed through a pointer.
    Signed-off-by: NEric Blake <eblake@redhat.com>
    Message-Id: <1455778109-6278-9-git-send-email-eblake@redhat.com>
    Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
    65551903
qapi-visit.py 11.0 KB