From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E324C3F2D8 for ; Wed, 4 Mar 2020 18:06:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 029EC21556 for ; Wed, 4 Mar 2020 18:06:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730019AbgCDSGo (ORCPT ); Wed, 4 Mar 2020 13:06:44 -0500 Received: from foss.arm.com ([217.140.110.172]:38130 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728926AbgCDSGn (ORCPT ); Wed, 4 Mar 2020 13:06:43 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C1E5831B; Wed, 4 Mar 2020 10:06:42 -0800 (PST) Received: from e121166-lin.cambridge.arm.com (e121166-lin.cambridge.arm.com [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3CDEC3F6C4; Wed, 4 Mar 2020 10:06:41 -0800 (PST) Date: Wed, 4 Mar 2020 18:06:35 +0000 From: Lorenzo Pieralisi To: Wei Liu Cc: Dexuan Cui , "Gustavo A. R. Silva" , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Sasha Levin , Andrew Murray , Bjorn Helgaas , "linux-hyperv@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] PCI: hv: Replace zero-length array with flexible-array member Message-ID: <20200304180635.GA21844@e121166-lin.cambridge.arm.com> References: <20200213005048.GA9662@embeddedor.com> <20200304175509.dwhn63omfzewaukv@debian> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200304175509.dwhn63omfzewaukv@debian> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 04, 2020 at 05:55:09PM +0000, Wei Liu wrote: > On Thu, Feb 13, 2020 at 03:43:40AM +0000, Dexuan Cui wrote: > > > From: linux-hyperv-owner@vger.kernel.org > > > On Behalf Of Gustavo A. R. Silva > > > Sent: Wednesday, February 12, 2020 4:51 PM > > > ... > > > The current codebase makes use of the zero-length array language > > > extension to the C90 standard, but the preferred mechanism to declare > > > variable-length types such as these ones is a flexible array member[1][2], > > > introduced in C99: > > > > > > struct foo { > > > int stuff; > > > struct boo array[]; > > > }; > > > > > > By making use of the mechanism above, we will get a compiler warning > > > in case the flexible array does not occur last in the structure, which > > > will help us prevent some kind of undefined behavior bugs from being > > > inadvertently introduced[3] to the codebase from now on. > > > > > > Also, notice that, dynamic memory allocations won't be affected by > > > this change: > > > > > > "Flexible array members have incomplete type, and so the sizeof operator > > > may not be applied. As a quirk of the original implementation of > > > zero-length arrays, sizeof evaluates to zero."[1] > > > > > > This issue was found with the help of Coccinelle. > > > > Looks good to me. Thanks, Gustavo! > > > > Reviewed-by: Dexuan Cui > > > > Lorenzo, will you be picking up this patch? It seems to me you've been > handling patches to pci-hyperv.c. This patch is not yet in pci/hv branch > in your repository. > > Let me know what you think. I shall pick it up, I checked patchwork and it was erroneously assigned to Bjorn, that's why I have not taken it yet. Fixed now, apologies, I will merge it shortly. Lorenzo