lkml.org 
[lkml]   [2023]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH][next] wifi: mt76: mt7921: Replace fake flex-arrays with flexible-array members
On Mon, Mar 20, 2023 at 03:56:54PM +0100, Simon Horman wrote:
> > struct mt7921_asar_cl {
> > @@ -85,7 +85,7 @@ struct mt7921_asar_fg {
> > u8 rsvd;
> > u8 nr_flag;
> > u8 rsvd1;
> > - u8 flag[0];
> > + u8 flag[];
>
> I am curious to know why DECLARE_FLEX_ARRAY isn't used here.

In contrast to the other structs, there is no object of type struct
mt7921_asar_fg declared in a union:

91 struct mt7921_acpi_sar {
92 u8 ver;
93 union {
94 struct mt7921_asar_dyn *dyn;
95 struct mt7921_asar_dyn_v2 *dyn_v2;
96 };
97 union {
98 struct mt7921_asar_geo *geo;
99 struct mt7921_asar_geo_v2 *geo_v2;
100 };
101 struct mt7921_asar_cl *countrylist;
102 struct mt7921_asar_fg *fg;
103 };

The DECLARE_FLEX_ARRAY() helper was created to declare flex-array members
in unions or alone in structs[1].

--
Gustavo

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays

\
 
 \ /
  Last update: 2023-03-27 01:09    [W:0.066 / U:0.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site