From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NsA6W-0003Z7-3p for qemu-devel@nongnu.org; Thu, 18 Mar 2010 03:25:16 -0400 Received: from [199.232.76.173] (port=58303 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsA6V-0003Yp-Lb for qemu-devel@nongnu.org; Thu, 18 Mar 2010 03:25:15 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NsA6T-0004bY-TF for qemu-devel@nongnu.org; Thu, 18 Mar 2010 03:25:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41831) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NsA6T-0004bS-F8 for qemu-devel@nongnu.org; Thu, 18 Mar 2010 03:25:13 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2I7PCaJ021977 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Mar 2010 03:25:12 -0400 Date: Thu, 18 Mar 2010 09:21:47 +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] [PATCH 4/5] virtio-balloon: 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 to remove assumption that vdev is 1st member of structure. Signed-off-by: Michael S. Tsirkin --- hw/virtio-balloon.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index 5a3be22..f80f6d0 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -43,7 +43,7 @@ typedef struct VirtIOBalloon static VirtIOBalloon *to_virtio_balloon(VirtIODevice *vdev) { - return (VirtIOBalloon *)vdev; + return container_of(vdev, VirtIOBalloon, vdev); } static void balloon_page(void *addr, int deflate) @@ -165,7 +165,7 @@ static void complete_stats_request(VirtIOBalloon *vb) static void virtio_balloon_receive_stats(VirtIODevice *vdev, VirtQueue *vq) { - VirtIOBalloon *s = DO_UPCAST(VirtIOBalloon, vdev, vdev); + VirtIOBalloon *s = to_virtio_balloon(vdev); VirtQueueElement *elem = &s->stats_vq_elem; VirtIOBalloonStat stat; size_t offset = 0; -- 1.7.0.2.280.gc6f05