From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NsA6M-0003VO-62 for qemu-devel@nongnu.org; Thu, 18 Mar 2010 03:25:06 -0400 Received: from [199.232.76.173] (port=58299 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsA6L-0003V0-OG for qemu-devel@nongnu.org; Thu, 18 Mar 2010 03:25:05 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NsA6K-0004aT-Hs for qemu-devel@nongnu.org; Thu, 18 Mar 2010 03:25:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61289) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NsA6K-0004aM-6L for qemu-devel@nongnu.org; Thu, 18 Mar 2010 03:25:04 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2I7P3hF023711 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Mar 2010 03:25:03 -0400 Date: Thu, 18 Mar 2010 09:21:38 +0200 From: "Michael S. Tsirkin" Message-ID: <605cf68362240dd9e7c41b36915a0f070f6c8a10.1268896694.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [Qemu-devel] [PATCH 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 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); -- 1.7.0.2.280.gc6f05