From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NsCIr-0005Um-SW for qemu-devel@nongnu.org; Thu, 18 Mar 2010 05:46:09 -0400 Received: from [199.232.76.173] (port=59692 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsCIr-0005UO-Cp for qemu-devel@nongnu.org; Thu, 18 Mar 2010 05:46:09 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NsCIq-00036l-AO for qemu-devel@nongnu.org; Thu, 18 Mar 2010 05:46:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22085) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NsCIp-00036f-U6 for qemu-devel@nongnu.org; Thu, 18 Mar 2010 05:46:08 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2I9k6YX017198 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Mar 2010 05:46:07 -0400 Date: Thu, 18 Mar 2010 11:42:42 +0200 From: "Michael S. Tsirkin" Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [Qemu-devel] [PATCHv2 2/5] virtio-net: remove layout assumptions List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: quintela@redhat.com, qemu-devel@nongnu.org Use container_of so we do not depend on vdev being first member. Signed-off-by: Michael S. Tsirkin --- hw/virtio-net.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index d962a75..ca843f8 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) @@ -873,7 +873,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); -- 1.7.0.2.280.gc6f05