[PATCH][next] wifi: mt76: mt7921: Replace fake flex-arrays with flexible-array members

Gustavo A. R. Silva gustavoars at kernel.org
Mon Mar 20 12:26:49 PDT 2023


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




More information about the linux-arm-kernel mailing list