Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace fake flexible array with C99 flexible-array member in drivers/net/ethernet/qlogic/netxen/netxen_nic.h #265

Closed
GustavoARSilva opened this issue Feb 24, 2023 · 1 comment
Assignees
Labels
-fstrict-flex-arrays=3 GCC-13 and -fstrict-flex-arrays=3 enabled [Idiom] fake flexible array [PATCH] Accepted A submitted patch has been accepted upstream [PATCH] Exists A patch exists to address the issue [Refactor] 0-element array Conversion away from zero-length array

Comments

@GustavoARSilva
Copy link
Collaborator

 841 typedef struct {
 842         /* These ring offsets are relative to data[0] below */
 843         __le32 rds_ring_offset; /* Offset to RDS config */
 844         __le32 sds_ring_offset; /* Offset to SDS config */
...
 852         u8  reserved[128];      /* save space for future expansion */
 853         /*  MUST BE 64-bit aligned.
 854            The following is packed:
 855            - N cardrsp_rds_rings
 856            - N cardrs_sds_rings */
 857         char data[0];
 858 } nx_cardrsp_rx_ctx_t;

-Warray-bounds warnings with GCC-13 and -fstrict-flex-arrays=3:

drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c:361:26: warning: array subscript <unknown> is outside array bounds ofchar[0]’ [-Warray-bounds=]
drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c:372:25: warning: array subscript <unknown> is outside array bounds ofchar[0]’ [-Warray-bounds=]
@GustavoARSilva GustavoARSilva added [Refactor] 0-element array Conversion away from zero-length array [Idiom] fake flexible array -fstrict-flex-arrays=3 GCC-13 and -fstrict-flex-arrays=3 enabled labels Feb 24, 2023
@GustavoARSilva GustavoARSilva self-assigned this Feb 24, 2023
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Mar 6, 2023
Zero-length arrays as fake flexible arrays are deprecated and we are
moving towards adopting C99 flexible-array members instead.

Transform zero-length array into flexible-array member in struct
nx_cardrsp_rx_ctx_t.

Address the following warnings found with GCC-13 and
-fstrict-flex-arrays=3 enabled:
drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c:361:26: warning: array subscript <unknown> is outside array bounds of ‘char[0]’ [-Warray-bounds=]
drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c:372:25: warning: array subscript <unknown> is outside array bounds of ‘char[0]’ [-Warray-bounds=]

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: KSPP#21
Link: KSPP#265
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
@GustavoARSilva
Copy link
Collaborator Author

@GustavoARSilva GustavoARSilva added the [PATCH] Exists A patch exists to address the issue label Mar 6, 2023
ammarfaizi2 pushed a commit to ammarfaizi2/linux-block that referenced this issue Mar 8, 2023
Zero-length arrays as fake flexible arrays are deprecated and we are
moving towards adopting C99 flexible-array members instead.

Transform zero-length array into flexible-array member in struct
nx_cardrsp_rx_ctx_t.

Address the following warnings found with GCC-13 and
-fstrict-flex-arrays=3 enabled:
drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c:361:26: warning: array subscript <unknown> is outside array bounds of ‘char[0]’ [-Warray-bounds=]
drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c:372:25: warning: array subscript <unknown> is outside array bounds of ‘char[0]’ [-Warray-bounds=]

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: KSPP/linux#21
Link: KSPP/linux#265
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/ZAZ57I6WdQEwWh7v@work
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
@GustavoARSilva GustavoARSilva added the [PATCH] Accepted A submitted patch has been accepted upstream label May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-fstrict-flex-arrays=3 GCC-13 and -fstrict-flex-arrays=3 enabled [Idiom] fake flexible array [PATCH] Accepted A submitted patch has been accepted upstream [PATCH] Exists A patch exists to address the issue [Refactor] 0-element array Conversion away from zero-length array
Projects
None yet
Development

No branches or pull requests

1 participant