Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755976AbcCTPoT (ORCPT ); Sun, 20 Mar 2016 11:44:19 -0400 Received: from www.linutronix.de ([62.245.132.108]:40934 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755562AbcCTPoB (ORCPT ); Sun, 20 Mar 2016 11:44:01 -0400 Date: Sun, 20 Mar 2016 16:42:29 +0100 (CET) From: Thomas Gleixner To: Wei Yang 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 In-Reply-To: <1458482251-7939-2-git-send-email-richard.weiyang@gmail.com> Message-ID: References: <1458482251-7939-1-git-send-email-richard.weiyang@gmail.com> <1458482251-7939-2-git-send-email-richard.weiyang@gmail.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 972 Lines: 29 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