From patchwork Thu Mar 18 07:21:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 48008 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BC430B7D14 for ; Thu, 18 Mar 2010 19:02:56 +1100 (EST) Received: from localhost ([127.0.0.1]:36496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsAfi-0001x2-GJ for incoming@patchwork.ozlabs.org; Thu, 18 Mar 2010 04:01:38 -0400 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 Received: from redhat.com (vpn1-6-158.ams2.redhat.com [10.36.6.158]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o2I7PAix001776; Thu, 18 Mar 2010 03:25:11 -0400 Date: Thu, 18 Mar 2010 09:21:47 +0200 From: "Michael S. Tsirkin" To: quintela@redhat.com, qemu-devel@nongnu.org Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH 4/5] virtio-balloon: remove layout assumptions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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;