qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/3] Clean up upcast from PCIDevice to I6300Stat


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 2/3] Clean up upcast from PCIDevice to I6300State
Date: Mon, 24 Aug 2009 15:44:58 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux)

Paul Brook <address@hidden> 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!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]