Re: [PATCH] [next] HID: hyperv: Replace one-element array with flexible-array member

From: Paulo Miguel Almeida
Date: Mon Oct 17 2022 - 05:30:48 EST


On Mon, Oct 17, 2022 at 10:30:54AM +0200, Benjamin Tissoires wrote:
> On Mon, Oct 17, 2022 at 9:51 AM Paulo Miguel Almeida
> <paulo.miguel.almeida.rodenas@xxxxxxxxx> wrote:
> >
> > One-element arrays are deprecated, and we are replacing them with
> > flexible array members instead. So, replace one-element array with
> > flexible-array member in structs synthhid_msg, synthhid_input_report,
> > pipe_prt_msg and refactor the rest of the code accordingly.
> >
> > This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
> > routines on memcpy() and help us make progress towards globally
> > enabling -fstrict-flex-arrays=3 [1].
> >
> > Link: https://github.com/KSPP/linux/issues/79
> > Link: https://github.com/KSPP/linux/issues/210
> > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 [1]
> >
> > Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@xxxxxxxxx>
> > ---
>
> FWIW, this is
> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@xxxxxxxxxx>
>
Thanks for reviewing this patch :-)

> > +++ b/drivers/hid/hid-hyperv.c
> > @@ -61,7 +61,7 @@ struct synthhid_msg_hdr {
> >
> > struct synthhid_msg {
> > struct synthhid_msg_hdr header;
> > - char data[1]; /* Enclosed message */
> > + char data[]; /* Enclosed message */
> > };
>
> IMO that struct has no real use. We just use it in
> mousevsc_on_receive() to dereference the first field only, the header.
> So how about we have a followup cleanup patch that just removes it and
> in mousevsc_on_receive() we convert those usages directly to struct
> synthhid_msg_hdr?
>
> Cheers,
> Benjamin

I'm happy to send a followup cleanup patch for that.

Paulo A.