Skip to content
  • Eric Blake's avatar
    d7bea75d
    qapi: Avoid use of misnamed DO_UPCAST() · d7bea75d
    Eric Blake authored
    
    
    The macro DO_UPCAST() is incorrectly named: it converts from a
    parent class to a derived class (which is a downcast).  Better,
    and more consistent with some of the other qapi visitors, is
    to use the container_of() macro through a to_FOO() helper.  Names
    like 'to_ov()' may be a bit short, but for a static helper it
    doesn't hurt too much, and matches existing practice in files
    like qmp-input-visitor.c.
    
    Our current definition of container_of() is weaker than
    DO_UPCAST(), in that it does not require the derived class to
    have Visitor as its first member, but this does not hurt our
    usage patterns in qapi visitors.
    
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
    Message-Id: <1454075341-13658-3-git-send-email-eblake@redhat.com>
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
    d7bea75d
    qapi: Avoid use of misnamed DO_UPCAST()
    Eric Blake authored
    
    
    The macro DO_UPCAST() is incorrectly named: it converts from a
    parent class to a derived class (which is a downcast).  Better,
    and more consistent with some of the other qapi visitors, is
    to use the container_of() macro through a to_FOO() helper.  Names
    like 'to_ov()' may be a bit short, but for a static helper it
    doesn't hurt too much, and matches existing practice in files
    like qmp-input-visitor.c.
    
    Our current definition of container_of() is weaker than
    DO_UPCAST(), in that it does not require the derived class to
    have Visitor as its first member, but this does not hurt our
    usage patterns in qapi visitors.
    
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
    Message-Id: <1454075341-13658-3-git-send-email-eblake@redhat.com>
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
Loading