Re: [PATCH v2 2/5] treewide: Replace open-coded flex arrays in unions

From: Marc Kleine-Budde
Date: Fri Aug 27 2021 - 13:09:58 EST


On 27.08.2021 09:08:19, Kees Cook wrote:
> > BTW: Is there opportunity for conversion, too?
> >
> > | drivers/net/can/peak_canfd/peak_pciefd_main.c:146:32: warning: array of flexible structures
>
> Oh, hrmpf. This isn't a sane use of flex arrays:
>
> struct __packed pucan_rx_msg {
> ...
> __le32 can_id;
> u8 d[];
> };
>
> struct pciefd_rx_dma {
> __le32 irq_status;
> __le32 sys_time_low;
> __le32 sys_time_high;
> struct pucan_rx_msg msg[];
> } __packed __aligned(4);
>
> I think that needs to be handled separately. How are you building to get
> that warning, by the way? I haven't seen that in my builds...

If compiling with C=1, sparse will complain about this.

regards,
Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |

Attachment: signature.asc
Description: PGP signature