[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87h7yfauiy.fsf@kamboji.qca.qualcomm.com>
Date: Mon, 23 Mar 2020 18:46:45 +0200
From: Kalle Valo <kvalo@...eaurora.org>
To: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
Cc: Jes Sorensen <jes.sorensen@...il.com>,
Joe Perches <joe@...ches.com>,
Ulrich Kunitz <kune@...ne-taler.de>,
"David S. Miller" <davem@...emloft.net>,
linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Kees Cook <keescook@...omium.org>
Subject: Re: [PATCH][next] zd1211rw/zd_usb.h: Replace zero-length array with flexible-array member
"Gustavo A. R. Silva" <gustavo@...eddedor.com> writes:
> On 3/10/20 5:34 PM, Jes Sorensen wrote:
>> On 3/10/20 6:31 PM, Gustavo A. R. Silva wrote:
>>>
>>>
>>> On 3/10/20 5:20 PM, Jes Sorensen wrote:
>>>> On 3/10/20 6:13 PM, Gustavo A. R. Silva wrote:
>>>>>
>>>>>
>>>>> On 3/10/20 5:07 PM, Jes Sorensen wrote:
>>>>>> As I stated in my previous answer, this seems more code churn than an
>>>>>> actual fix. If this is a real problem, shouldn't the work be put into
>>>>>> fixing the compiler to handle foo[0] instead? It seems that is where the
>>>>>> real value would be.
>>>>>
>>>>> Yeah. But, unfortunately, I'm not a compiler guy, so I'm not able to fix the
>>>>> compiler as you suggest. And I honestly don't see what is so annoying/disturbing
>>>>> about applying a patch that removes the 0 from foo[0] when it brings benefit
>>>>> to the whole codebase.
>>>>
>>>> My point is that it adds what seems like unnecessary churn, which is not
>>>> a benefit, and it doesn't improve the generated code.
>>>>
>>>
>>> As an example of one of the benefits of this is that the compiler won't trigger
>>> a warning in the following case:
>>>
>>> struct boo {
>>> int stuff;
>>> struct foo array[0];
>>> int morestuff;
>>> };
>>>
>>> The result of the code above is an undefined behavior.
>>>
>>> On the other hand in the case below, the compiles does trigger a warning:
>>>
>>> struct boo {
>>> int stuff;
>>> struct foo array[];
>>> int morestuff;
>>> };
>>
>> Right, this just underlines my prior argument, that this should be fixed
>> in the compiler.
>>
>
> In the meantime it's not at all harmful to do something about it in the codebase.
Cleanup patches are not always harmful, at least they can create bugs
and conflicts. But I think in this case there are clear benefits for the
churn so I'm going to apply these.
Sorry Jes :)
--
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Powered by blists - more mailing lists