mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: joro@8bytes.org, jiang.liu@linux.intel.com,
	iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [Patch V2 1/4] iommu/vt-d: replace *hdr with hdr[0] in struct dmar_drhd_unit
Date: Sun, 20 Mar 2016 16:42:29 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.11.1603201631280.3978@nanos> (raw)
In-Reply-To: <1458482251-7939-2-git-send-email-richard.weiyang@gmail.com>

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

  reply	other threads:[~2016-03-20 15:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-20 13:57 [Patch V2 0/4] Code refine for Intel IOMMU Wei Yang
2016-03-20 13:57 ` [Patch V2 1/4] iommu/vt-d: replace *hdr with hdr[0] in struct dmar_drhd_unit Wei Yang
2016-03-20 15:42   ` Thomas Gleixner [this message]
2016-03-21 14:46     ` Wei Yang
2016-03-21 16:53       ` Thomas Gleixner
2016-03-21 22:31         ` Wei Yang
2016-03-20 13:57 ` [Patch V2 2/4] iommu/vt-d: use zero-sized array in DMAR related ACPI structures Wei Yang
2016-03-20 13:57 ` [Patch V2 3/4] iommu/vt-d: check Register Base Address at the beginning of dmar_parse_one_drhd() Wei Yang
2016-03-20 13:57 ` [Patch V2 4/4] iommu/vt-d: refine dmar_acpi_dev_scope_init() with dmar_walk_dmar_table() Wei Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.11.1603201631280.3978@nanos \
    --to=tglx@linutronix.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jiang.liu@linux.intel.com \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=richard.weiyang@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®