2022-08-29 22:12:38

by Gustavo A. R. Silva

[permalink] [raw]
Subject: [PATCH][next] can: etas_es58x: Replace zero-length array with DECLARE_FLEX_ARRAY() helper

Zero-length arrays are deprecated and we are moving towards adopting
C99 flexible-array members, instead. So, replace zero-length array
declaration in union es58x_urb_cmd with the new DECLARE_FLEX_ARRAY()
helper macro.

This helper allows for a flexible-array member in a union.

Link: https://github.com/KSPP/linux/issues/193
Link: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Signed-off-by: Gustavo A. R. Silva <[email protected]>
---
drivers/net/can/usb/etas_es58x/es58x_core.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.h b/drivers/net/can/usb/etas_es58x/es58x_core.h
index d769bdf740b7..640fe0a1df63 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.h
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.h
@@ -222,7 +222,7 @@ union es58x_urb_cmd {
u8 cmd_type;
u8 cmd_id;
} __packed;
- u8 raw_cmd[0];
+ DECLARE_FLEX_ARRAY(u8, raw_cmd);
};

/**
--
2.34.1


2022-08-29 22:50:20

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH][next] can: etas_es58x: Replace zero-length array with DECLARE_FLEX_ARRAY() helper

On Mon, Aug 29, 2022 at 04:50:59PM -0500, Gustavo A. R. Silva wrote:
> Zero-length arrays are deprecated and we are moving towards adopting
> C99 flexible-array members, instead. So, replace zero-length array
> declaration in union es58x_urb_cmd with the new DECLARE_FLEX_ARRAY()
> helper macro.
>
> This helper allows for a flexible-array member in a union.
>
> Link: https://github.com/KSPP/linux/issues/193
> Link: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
> Signed-off-by: Gustavo A. R. Silva <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2022-08-30 01:30:59

by Vincent MAILHOL

[permalink] [raw]
Subject: Re: [PATCH][next] can: etas_es58x: Replace zero-length array with DECLARE_FLEX_ARRAY() helper

On Tue. 30 Aug. 2022 at 07:15, Kees Cook <[email protected]> wrote:
> On Mon, Aug 29, 2022 at 04:50:59PM -0500, Gustavo A. R. Silva wrote:
> > Zero-length arrays are deprecated and we are moving towards adopting
> > C99 flexible-array members, instead. So, replace zero-length array
> > declaration in union es58x_urb_cmd with the new DECLARE_FLEX_ARRAY()
> > helper macro.
> >
> > This helper allows for a flexible-array member in a union.
> >
> > Link: https://github.com/KSPP/linux/issues/193
> > Link: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
> > Signed-off-by: Gustavo A. R. Silva <[email protected]>
>
> Reviewed-by: Kees Cook <[email protected]>

Acked-by: Vincent Mailhol <[email protected]>


Yours sincerely,
Vincent Mailhol

2022-09-06 07:11:30

by Marc Kleine-Budde

[permalink] [raw]
Subject: Re: [PATCH][next] can: etas_es58x: Replace zero-length array with DECLARE_FLEX_ARRAY() helper

On 29.08.2022 16:50:59, Gustavo A. R. Silva wrote:
> Zero-length arrays are deprecated and we are moving towards adopting
> C99 flexible-array members, instead. So, replace zero-length array
> declaration in union es58x_urb_cmd with the new DECLARE_FLEX_ARRAY()
> helper macro.
>
> This helper allows for a flexible-array member in a union.
>
> Link: https://github.com/KSPP/linux/issues/193
> Link: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
> Signed-off-by: Gustavo A. R. Silva <[email protected]>

Applied to linux-can-next.

Thanks,
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 |


Attachments:
(No filename) (844.00 B)
signature.asc (499.00 B)
Download all attachments