staging: greybus: Replace zero-length array by DECLARE_FLEX_ARRAY() helper
authorDeepak R Varma <drv@mailo.com>
Wed, 4 Jan 2023 15:18:38 +0000 (20:48 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Jan 2023 18:18:47 +0000 (19:18 +0100)
The code currently uses C90 standard extension based zero length array
struct which is now deprecated and the new C99 standard extension of
flexible array declarations are to be used instead. Also, the macro
DECLARE_FLEX_ARRAY() allows to use single flexible array member in a
structure. Refer to these links [1], [2], and [3] for details.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://lore.kernel.org/lkml/YxKY6O2hmdwNh8r8@work
[3] https://lore.kernel.org/lkml/20210827163015.3141722-2-keescook@chromium.org/

Issue identified using Coccinelle flexible_array.cocci semantic patch.

Signed-off-by: Deepak R Varma <drv@mailo.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Link: https://lore.kernel.org/r/Y7WYzkIOqaHOxDDS@qemulion
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/greybus/usb.c

index 8e9d9d5..b7badf8 100644 (file)
@@ -27,7 +27,7 @@ struct gb_usb_hub_control_request {
 };
 
 struct gb_usb_hub_control_response {
-       u8 buf[0];
+       DECLARE_FLEX_ARRAY(u8, buf);
 };
 
 struct gb_usb_device {