staging: greybus: Replace zero-length array by DECLARE_FLEX_ARRAY() helper
PATCH 1/1 staging: greybus: Replace zero-length array by DECLARE_FLEX_ARRAY() helper
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] for details.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://lkml.kernel.org/r/YxKY6O2hmdwNh8r8@work
Issue identified using Coccinelle flexible_array.cocci semantic patch.
--- drivers/staging/greybus/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/greybus/usb.c +1 -1
@@ -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 {
--
2.34.1
Quoted 5 lines · Deepak R Varma
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] for details.
Thank you for citing some references in your commit, it's a good and helpful practice. This might have been another helpful one:
https://lore.kernel.org/lkml/[email protected]/
Quoted 2 lines
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://lkml.kernel.org/r/YxKY6O2hmdwNh8r8@work
FYI, Linux mailing lists hosted by kernel.org are normally cited using "lore.kernel.org" now, e.g.:
https://lore.kernel.org/lkml/YxKY6O2hmdwNh8r8@work
Your patch is fine, this is just so you can consider this in the future.
Quoted 3 lines
Issue identified using Coccinelle
flexible_array.coccisemantic patch.Signed-off-by Deepak R Varma <[email protected]>
Looks good to me.
Quoted 22 lines
--- drivers/staging/greybus/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/greybus/usb.c +1
-2@@ -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 { --2.34.1
Quoted 7 lines · Alex Elder
Quoted 5 lines · Deepak R Varma
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] for details.
Quoted 5 lines
Thank you for citing some references in your commit, it's a good and helpful practice. This might have been another helpful one:
Hello Alex,
Thank you so much for the feedback. I will include the additional reference and send in a v2.
Quoted 9 lines
Quoted 3 lines
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://lkml.kernel.org/r/YxKY6O2hmdwNh8r8@workFYI, Linux mailing lists hosted by kernel.org are normally cited using "lore.kernel.org" now, e.g.:
https://lore.kernel.org/lkml/YxKY6O2hmdwNh8r8@work
Your patch is fine, this is just so you can consider this in the future.
Sure, I will. This is very helpful to know.
Quoted 6 lines
Quoted 4 lines
Issue identified using Coccinelle
flexible_array.coccisemantic patch.Signed-off-by Deepak R Varma <[email protected]>Looks good to me.
Appreciate your time for the review and comments. I will include the reviewed by tag in my v2.
Regards,
./drv
Quoted 26 lines
Reviewed-by Alex Elder <[email protected]>Quoted 22 lines
--- drivers/staging/greybus/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/greybus/usb.c +1
-2@@ -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 { --2.34.1