From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MfZr8-0000lI-99 for qemu-devel@nongnu.org; Mon, 24 Aug 2009 09:45:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MfZr3-0000gd-Ke for qemu-devel@nongnu.org; Mon, 24 Aug 2009 09:45:05 -0400 Received: from [199.232.76.173] (port=49068 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MfZr3-0000gE-8Y for qemu-devel@nongnu.org; Mon, 24 Aug 2009 09:45:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39112) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MfZr2-0001Wv-Oa for qemu-devel@nongnu.org; Mon, 24 Aug 2009 09:45:01 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7ODixCV019997 for ; Mon, 24 Aug 2009 09:44:59 -0400 Received: from pike.pond.sub.org (vpn-10-6.str.redhat.com [10.32.10.6]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7ODixbx014673 for ; Mon, 24 Aug 2009 09:44:59 -0400 Subject: Re: [Qemu-devel] [PATCH 2/3] Clean up upcast from PCIDevice to I6300State References: <1250843494-28326-1-git-send-email-armbru@redhat.com> <1250843494-28326-3-git-send-email-armbru@redhat.com> <200908241259.06409.paul@codesourcery.com> From: Markus Armbruster Date: Mon, 24 Aug 2009 15:44:58 +0200 In-Reply-To: <200908241259.06409.paul@codesourcery.com> (Paul Brook's message of "Mon\, 24 Aug 2009 12\:59\:06 +0100") Message-ID: <8763cdpbqd.fsf@pike.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Paul Brook writes: >> /* Device state. */ >> struct I6300State { >> - PCIDevice dev; /* PCI device state, must be first field. */ >> + PCIDevice dev; >>... >> - I6300State *d = (I6300State *) dev; >> + I6300State *d = container_of(dev, I6300State, dev); > > I'm pretty sure this is wrong, and code elsewhere still requires the PCIDevice > be the first field in I6300State. e.g. i6300esb_pc_init. Did you actually try > putting dev at a nonzero offset? I believe this commit is correct, because no code remains in wdt_i6300esb.c that relies on the zero offset, and qdev is not yet in play. However, the *next* commit (conversion to qdev) is wrong if qdev requires the PCIDevice at offset zero (not obvious to me, document it?). I'll use DO_UPCAST() when I respin the patch series, to match usage elsewhere. Thanks!