Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5321944ybv; Mon, 17 Feb 2020 17:26:16 -0800 (PST) X-Google-Smtp-Source: APXvYqxHwh2QUhxOyIC63rNEkB17sXu7/bpJqPQJ+y4CZz6RjPNMRSt1EE7VxPW7TsRiUKMGmul9 X-Received: by 2002:aca:2416:: with SMTP id n22mr1064883oic.169.1581989176450; Mon, 17 Feb 2020 17:26:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581989176; cv=none; d=google.com; s=arc-20160816; b=RUBvRfNCibglt/w9L8wt6NurIt/1I8AXazz4vaSNEhinnm4dJwgnQOPwT+kWMlNK2a FxZM/RLOCYyfGt/taKfF03BG6wVeF8IGQvyIRTcmChVx0Xr6uIVr2seORN8zMbqxYgC4 Gm/mhZJgXcwSL8E/Zr6iNnWRIamurTOekEh3XOB8zqU/S1mAEs/7Qtv+5QBR0ddGGqyp pK8hCMIRnN1bN4DtM5QcFOn6xgIQxeL+4Uog/zFBUGShddt8Zfrj0hlLgLC/kAbAak41 gjlhTiIu1sG+0m2BHIgzva85+KqXGmVg3qMG7t+3BL8iuKeimlBKwmq7LUTSf9N5s5E8 m65g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=aHC68Gt/bTCwhaQGD8YtBd8mxysiY1ksslwULIMw21M=; b=ocdDzRWbbF64mtnm1kGqxXAVPcEVO+yypO/bEy/qBYpaNzWEYRYwruyxKzz8gv+y2m jguzbigwne6MdSkkTBXEFp/ECuK1rifwHd56BL6WlAMF3mGAUnC8MDo8vY2uGIbphfyj ek8mHFgouOeAj0hhqLifhzYKyLf384OdO5ruZF++gfWv+kGECmADtMk29DtzNSOqCLl3 9mwixEd1ppWxvxpbLJXas3n8Ed4lsgE/ijF9jnCNYDdbtakaiLfCwFbWfsS5Ikp89lu8 Y0p2eQT975ysUYN/IK8Vo+G62rMRt6uYCs/ldYxZ1Tmh/bVKidZT3N7eanSHhSe6wg7a kjvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="xbEqK3B/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17si1022285otp.236.2020.02.17.17.26.04; Mon, 17 Feb 2020 17:26:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="xbEqK3B/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726291AbgBRBZt (ORCPT + 99 others); Mon, 17 Feb 2020 20:25:49 -0500 Received: from conssluserg-02.nifty.com ([210.131.2.81]:34042 "EHLO conssluserg-02.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726070AbgBRBZt (ORCPT ); Mon, 17 Feb 2020 20:25:49 -0500 Received: from mail-vk1-f178.google.com (mail-vk1-f178.google.com [209.85.221.178]) (authenticated) by conssluserg-02.nifty.com with ESMTP id 01I1Pjfa029198; Tue, 18 Feb 2020 10:25:45 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com 01I1Pjfa029198 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1581989146; bh=aHC68Gt/bTCwhaQGD8YtBd8mxysiY1ksslwULIMw21M=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=xbEqK3B/f3ZeMYMcEPTAwBLvw/Ioli6bXibu/eckH3BDDXYHgqFmWCrnJYxXXOyGO AFeSVqb5NsZHr8kjUSTnwPHpgJgcWnajxN4MDVTrRLBSIERI1ol1T69DCm+lISgKQs 4wWoHI+CoQSGN9EKnI0jtyJik53CnvaFH4mxJofHuhgFEPNlQfB/vcXtEPErRdL1/y c1wLpig6ijRKdqUor0kQTVWy3ygub06fsVPGUIH4PYniCUj0HQZDtbiIexE/aNURzr j31xvcEE4jSd2F/XdiuXtI5YUcioAO02a17Gus4CVxAmR73eAkvlpogH7wTwAv6CIN h4kbOzU+id4Rw== X-Nifty-SrcIP: [209.85.221.178] Received: by mail-vk1-f178.google.com with SMTP id t129so5096644vkg.6; Mon, 17 Feb 2020 17:25:45 -0800 (PST) X-Gm-Message-State: APjAAAW08EiFdmzt9DTEhGkJWYyhxmhcGeSYzBl/9HMu/tRM/qWIW5Le MJejCxlktyp1zjb8HoZt42KVQWPsLClRRPe/8v4= X-Received: by 2002:a1f:6344:: with SMTP id x65mr6933830vkb.26.1581989144317; Mon, 17 Feb 2020 17:25:44 -0800 (PST) MIME-Version: 1.0 References: <20200211210618.GA29823@embeddedor> In-Reply-To: <20200211210618.GA29823@embeddedor> From: Masahiro Yamada Date: Tue, 18 Feb 2020 10:25:08 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] gpio: uniphier: Replace zero-length array with flexible-array member To: "Gustavo A. R. Silva" Cc: Linus Walleij , Bartosz Golaszewski , "open list:GPIO SUBSYSTEM" , linux-arm-kernel , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 12, 2020 at 6:03 AM Gustavo A. R. Silva wrote: > > 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 > inadvertenly introduced[3] to the codebase from now on. > > This issue was found with the help of Coccinelle. > > [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html > [2] https://github.com/KSPP/linux/issues/21 > [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") > > Signed-off-by: Gustavo A. R. Silva Acked-by: Masahiro Yamada > --- > drivers/gpio/gpio-uniphier.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c > index 0f662b297a95..9843638d99d0 100644 > --- a/drivers/gpio/gpio-uniphier.c > +++ b/drivers/gpio/gpio-uniphier.c > @@ -33,7 +33,7 @@ struct uniphier_gpio_priv { > struct irq_domain *domain; > void __iomem *regs; > spinlock_t lock; > - u32 saved_vals[0]; > + u32 saved_vals[]; > }; > > static unsigned int uniphier_gpio_bank_to_reg(unsigned int bank) > -- > 2.25.0 > -- Best Regards Masahiro Yamada