From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: serial: ti_usb_3410_5052: Replace zero-length array with flexible-array member
Date: Wed, 12 Feb 2020 13:04:09 -0600 [thread overview]
Message-ID: <245fb407-d5d3-f0ce-1909-ec1febb55c93@embeddedor.com> (raw)
In-Reply-To: <20200212075929.GE4150@localhost>
On 2/12/20 01:59, Johan Hovold wrote:
> On Tue, Feb 11, 2020 at 05:24:20PM -0600, 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.
>
> Same here, the scripts may need to be updated as you missed a couple of
> instances:
>
> $ git grep '\[0\];' drivers/usb/serial
> ...
> drivers/usb/serial/io_usbvend.h: __u8 Data[0]; // Data starts here
> drivers/usb/serial/io_usbvend.h: __u8 Data[0]; // Download starts here
> ...
>
> Could you replace these as well so that is done in one patch per
> subsystem?
>
Sure thing. I'll do that.
Thanks for the feedback.
--
Gustavo
prev parent reply other threads:[~2020-02-12 19:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-11 23:24 [PATCH] USB: serial: ti_usb_3410_5052: Replace zero-length array with flexible-array member Gustavo A. R. Silva
2020-02-12 7:59 ` Johan Hovold
2020-02-12 19:04 ` Gustavo A. R. Silva [this message]
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=245fb407-d5d3-f0ce-1909-ec1febb55c93@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).