Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5763194ybv; Tue, 11 Feb 2020 23:22:55 -0800 (PST) X-Google-Smtp-Source: APXvYqyZ5K2tCxhutE0sfI341VoY/gVupObhGevmjFK4mwFNCMbr9N8kqQisXMTnCVMvkWM0e9la X-Received: by 2002:a05:6808:a9c:: with SMTP id q28mr5421046oij.176.1581492175767; Tue, 11 Feb 2020 23:22:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581492175; cv=none; d=google.com; s=arc-20160816; b=TgI5iHLaNGVVfxQaNPmICGoTcXjexzWtbOWH3KuNBFrBDw2EJagCvFz3mspJNc4r4t imprubSJI1NTXlY6j1OPGV7BiCLa+hjpqTHfUUAU/ZXdslCO0WxwrqofR6fSYjWAkvTs lvE/+/BfNhN31XLIR1xnQf+zd/n9hEprb8L5+bFqpR7Yg6FWjW1300JRmbZfwT5JHpEC e6WJ/mQkA85Jz8Dib40/ifV5FZp6q5qDIxXk8ozrrGwmFytHckqhsKLQUXZkfKmqxiJv yFke/HxdaSVqJlm7UlfSlZ7RJLBtkXnvjcZmoZjmkdDwhFzYkNI1b6Gvg1t5UEdZa5JK /z6g== 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; bh=j+IIIiLxT7RnMEOjFvfDSmF1Bvf4Q7q8NLRdkGyRnxg=; b=seeiukOJSMboGwrBiidi/BW7vnEUO6PuEG/nuK6/D9MVj/0xdyv23PAgIpQLOm7a3f BDUoxznBqRdxMLVy4l/Le6vtkM/O+SfM2fCf7mAbFaZRv5ceHDyisFrJXNcOrVT0y9Di vRRj0DjlHtFhJeRbTlzGgsRvyO9G3Mr80ocn0wA0A36PlYUoS/DPrXx590QsbrSI4o1D JTaDTgDHfn0SeFN43LbuYnTCp2Da/GmuqjhJyyHBBLsjndn6yXexXC/HyRgwo3gqyOVU qUU5DEwqF7ZJyA3nfPx79mHUoYzel7eVRNj7WXkENtuSWh5F8BssP8EMcfSL92agYrPH bVjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QeNjMTZo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e15si3274424otq.237.2020.02.11.23.22.43; Tue, 11 Feb 2020 23:22:55 -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=@linaro.org header.s=google header.b=QeNjMTZo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728393AbgBLHVZ (ORCPT + 99 others); Wed, 12 Feb 2020 02:21:25 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:42890 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728392AbgBLHVZ (ORCPT ); Wed, 12 Feb 2020 02:21:25 -0500 Received: by mail-wr1-f66.google.com with SMTP id k11so849870wrd.9 for ; Tue, 11 Feb 2020 23:21:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=j+IIIiLxT7RnMEOjFvfDSmF1Bvf4Q7q8NLRdkGyRnxg=; b=QeNjMTZo3cCSAXF10gWV74TGaKosijV1vvCEv1hT0i9ekozYvZBkZgkFI+33j3HDEQ nZwZL09OYeIOXx44Qbg0v/Gt58+vn4pybDIMfL1RvvTnPfCk9anhB3SBsaIJZOivQLB5 owvJdHyTAxU5LhftgojFG6mtS/GrAFgRshSz5I/jE8ZSiRRuVceM/Xc+fN2AmtwIaUR+ URFZt7MaYYzmsE1ykJQLTZ+kFmq5d8gCGyNEZ0H3FXouFVST3DZX7Isz1SYY+7RySCLD /yGgvufx3ewwWTOgDeFFZKnVjygoOqiI1TKBtcIwDwpSkIWWjqw5hGMIHg2ywyJaNIHt o+FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=j+IIIiLxT7RnMEOjFvfDSmF1Bvf4Q7q8NLRdkGyRnxg=; b=hEtUONn7xVcv4QVCdErr/W3ZM4e2NfyncatpmtdX2FKkJbQCXQf4gGIC97OgU9TtdQ GVzUaxyO5uZvq8uX4KdxInzndF2S1O4w88mjzwvWAxo34HCTWLEop2TNanddqlaocfAQ COHlBTNIE0uwWiRBb1btxlgTOKKrd30y8db1bMiIUPMhghvFPdtfS/pUp9hCI3FVc9JZ XJVXXSDMFQVgehYIeUBwrB8E4RXuYdd6VUSjCxswRvr/RU9YIkNygIBfJrdK1bcklfsS OLlOsqepk4I+Df2qazYaBx3wsgR3XymjxrpxpYe8VHDW8ErsF9UcYcEi0OlUCfN/5l/C SwDA== X-Gm-Message-State: APjAAAWqTxzdn+51yHY9wiAmPRClk8RmkN6AyCFMLLFNc7owFHUF+WF6 TxLTsDUdhxqM26X9kp3TO+yT1NCY8SYjM9DguGLp10jUuBo= X-Received: by 2002:a5d:65cf:: with SMTP id e15mr13277372wrw.126.1581492083142; Tue, 11 Feb 2020 23:21:23 -0800 (PST) MIME-Version: 1.0 References: <20200211231421.GA15697@embeddedor> In-Reply-To: <20200211231421.GA15697@embeddedor> From: Ard Biesheuvel Date: Wed, 12 Feb 2020 07:21:12 +0000 Message-ID: Subject: Re: [PATCH] efi/apple-properties: Replace zero-length array with flexible-array member To: "Gustavo A. R. Silva" Cc: linux-efi , 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, 12 Feb 2020 at 00:11, 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 Queued in efi/next Thanks, > --- > drivers/firmware/efi/apple-properties.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/efi/apple-properties.c b/drivers/firmware/efi/apple-properties.c > index 0e206c9e0d7a..590c9003f3b4 100644 > --- a/drivers/firmware/efi/apple-properties.c > +++ b/drivers/firmware/efi/apple-properties.c > @@ -31,7 +31,7 @@ __setup("dump_apple_properties", dump_properties_enable); > struct dev_header { > u32 len; > u32 prop_count; > - struct efi_dev_path path[0]; > + struct efi_dev_path path[]; > /* > * followed by key/value pairs, each key and value preceded by u32 len, > * len includes itself, value may be empty (in which case its len is 4) > @@ -42,7 +42,7 @@ struct properties_header { > u32 len; > u32 version; > u32 dev_count; > - struct dev_header dev_header[0]; > + struct dev_header dev_header[]; > }; > > static void __init unmarshal_key_value_pairs(struct dev_header *dev_header, > -- > 2.25.0 >