From patchwork Mon Oct 8 10:45:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 189981 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AFDA62C030F for ; Mon, 8 Oct 2012 21:45:32 +1100 (EST) Received: from localhost ([::1]:36796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLAq0-0006na-Sd for incoming@patchwork.ozlabs.org; Mon, 08 Oct 2012 06:45:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLApt-0006nO-Fw for qemu-devel@nongnu.org; Mon, 08 Oct 2012 06:45:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLApn-0005R2-IP for qemu-devel@nongnu.org; Mon, 08 Oct 2012 06:45:21 -0400 Received: from thoth.sbs.de ([192.35.17.2]:28512) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLApn-0005OJ-8Y for qemu-devel@nongnu.org; Mon, 08 Oct 2012 06:45:15 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.13.6/8.13.6) with ESMTP id q98AjCvb000647; Mon, 8 Oct 2012 12:45:12 +0200 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id q98AjCQ8002166; Mon, 8 Oct 2012 12:45:12 +0200 Message-ID: <5072AEB8.8020706@siemens.com> Date: Mon, 08 Oct 2012 12:45:12 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Alex Williamson , qemu-devel X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.2 Subject: [Qemu-devel] [PATCH] vfio: Fix BAR->VFIODevice translation in vfio_bar_read/write X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org DO_UPCAST is supposed to translate from the first member of a struct to that struct, not from arbitrary ones. And it (usually) breaks the build when neglecting this rule. Use container_of to fix the build breakage and likely also the runtime behavior. Signed-off-by: Jan Kiszka --- hw/vfio_pci.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c index a1eeced..d36d50e 100644 --- a/hw/vfio_pci.c +++ b/hw/vfio_pci.c @@ -601,7 +601,7 @@ static void vfio_bar_write(void *opaque, target_phys_addr_t addr, * which access will service the interrupt, so we're potentially * getting quite a few host interrupts per guest interrupt. */ - vfio_eoi(DO_UPCAST(VFIODevice, bars[bar->nr], bar)); + vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr])); } static uint64_t vfio_bar_read(void *opaque, @@ -641,7 +641,7 @@ static uint64_t vfio_bar_read(void *opaque, __func__, bar->nr, addr, size, data); /* Same as write above */ - vfio_eoi(DO_UPCAST(VFIODevice, bars[bar->nr], bar)); + vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr])); return data; }