Message ID | 605cf68362240dd9e7c41b36915a0f070f6c8a10.1268896694.git.mst@redhat.com |
---|---|
State | New |
Headers | show |
diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 5edb354..ae7751c 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -64,7 +64,7 @@ typedef struct VirtIONet static VirtIONet *to_virtio_net(VirtIODevice *vdev) { - return (VirtIONet *)vdev; + return container_of(vdev, VirtIONet, vdev); } static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config) @@ -874,7 +874,7 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf) void virtio_net_exit(VirtIODevice *vdev) { - VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev); + VirtIONet *n = to_virtio_net(vdev); qemu_purge_queued_packets(&n->nic->nc);
Use container_of so we do not depend on vdev being first member. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> --- hw/virtio-net.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)