[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZMkSIfUEnvYvHyZx@lincoln>
Date: Tue, 1 Aug 2023 16:09:37 +0200
From: Larysa Zaremba <larysa.zaremba@...el.com>
To: Atul Raut <rauji.raut@...il.com>
CC: Larysa Zaremba <larysa.zaremba@...el.com>, Atul Raut
<rauji.raut@...il.com>, <avem@...emloft.net>, <netdev@...r.kernel.org>,
<kuba@...nel.org>, <pabeni@...hat.com>, <rafal@...ecki.pl>,
<linux-kernel-mentees@...ts.linuxfoundation.org>
Subject: Re: [PATCH] net/macmace: Replace zero-length array with
DECLARE_FLEX_ARRAY() helper
On Mon, Jul 31, 2023 at 10:38:01AM +0300, Leon Romanovsky wrote:
> On Sun, Jul 30, 2023 at 04:14:42PM -0700, Atul Raut wrote:
> > Since zero-length arrays are deprecated, we are replacing
> > them with C99 flexible-array members. As a result, instead
> > of declaring a zero-length array, use the new
> > DECLARE_FLEX_ARRAY() helper macro.
> >
> > This fixes warnings such as:
> > ./drivers/net/ethernet/apple/macmace.c:80:4-8: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
> >
> > Signed-off-by: Atul Raut <rauji.raut@...il.com>
> > ---
> > drivers/net/ethernet/apple/macmace.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/apple/macmace.c b/drivers/net/ethernet/apple/macmace.c
> > index 8fcaf1639920..8775c3234e91 100644
> > --- a/drivers/net/ethernet/apple/macmace.c
> > +++ b/drivers/net/ethernet/apple/macmace.c
> > @@ -77,7 +77,7 @@ struct mace_frame {
> > u8 pad4;
> > u32 pad5;
> > u32 pad6;
> > - u8 data[1];
> > + DECLARE_FLEX_ARRAY(u8, data);
>
> But data[1] is not zero-length array.
>
So, please, if you are certain that data should be a flexible array,
send v2 without calling data a zero-length array. Also, with such change, I
think driver code could be improved in many places in the same patchset.
> > /* And frame continues.. */
> > };
> >
> > --
> > 2.34.1
> >
> >
>
Powered by blists - more mailing lists