lkml.org 
[lkml]   [2020]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] treewide: Replace zero-length arrays with flexible-array member
From
Date


On 2/11/20 13:35, Kees Cook wrote:
> On Tue, Feb 11, 2020 at 11:41:26AM -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
>> unadvertenly introduced[3] to the codebase from now on.
>
> Is there a compiler warning we can enable to avoid new 0-byte arrays
> from entering the kernel source tree? I can only find "-pedantic" which
> enables way too many other checks.
>

Months ago, I only found -pedantic, too. And we definitely don't want
to use it for this. :/

--
Gustavo

\
 
 \ /
  Last update: 2020-02-11 21:14    [W:1.503 / U:1.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site