[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.11.1603201631280.3978@nanos>
Date: Sun, 20 Mar 2016 16:42:29 +0100 (CET)
From: Thomas Gleixner <tglx@...utronix.de>
To: Wei Yang <richard.weiyang@...il.com>
cc: joro@...tes.org, jiang.liu@...ux.intel.com,
iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org
Subject: Re: [Patch V2 1/4] iommu/vt-d: replace *hdr with hdr[0] in struct
dmar_drhd_unit
On Sun, 20 Mar 2016, Wei Yang wrote:
> hdr in struct dmar_drhd_unit is used to point the DMAR hardware unit copied
> at the end of struct dmar_drhd_unit. One zero-sized array may be more
> elegant for this purpose.
You forget to tell why.
> This patch replace *hdr with hdr[0] in struct dmar_drhd_unit.
>
> Besides this, this patch includes other two changes:
> 1. remove unnecessary type cast in dmar_table_detect()
Again. Why is it not necessary?
> 2. type cast from acpi_dmar_header to acpi_dmar_hardware_unit directly
Don't even think about doing that. container_of() is there for a reason.
Your change works today, because the embedded structure is the first one in
the containing structure. If the containing structure gets reordered later,
the whole thing will explode in hard to debug ways.
Even if such a reordering is unlikely in that ACPI case, we just don't do
that. It's bad and sloppy coding style. The generated code is the same.
Thanks,
tglx
Powered by blists - more mailing lists