From patchwork Thu Mar 18 09:42: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: 48017 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 D39FCB7CEF for ; Thu, 18 Mar 2010 21:02:51 +1100 (EST) Received: from localhost ([127.0.0.1]:53520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsCX2-0005uH-3W for incoming@patchwork.ozlabs.org; Thu, 18 Mar 2010 06:00:48 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NsCIy-0005Yb-0r for qemu-devel@nongnu.org; Thu, 18 Mar 2010 05:46:16 -0400 Received: from [199.232.76.173] (port=59697 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NsCIx-0005Xx-3A for qemu-devel@nongnu.org; Thu, 18 Mar 2010 05:46:15 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NsCIv-00037H-SZ for qemu-devel@nongnu.org; Thu, 18 Mar 2010 05:46:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59213) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NsCIv-00037B-H2 for qemu-devel@nongnu.org; Thu, 18 Mar 2010 05:46:13 -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 o2I9kCjw023262 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Mar 2010 05:46:12 -0400 Received: from redhat.com (vpn1-6-158.ams2.redhat.com [10.36.6.158]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o2I9kAYD002114; Thu, 18 Mar 2010 05:46:11 -0400 Date: Thu, 18 Mar 2010 11:42: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.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCHv2 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 f8ccc00..21687e3 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;