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 include/linux/platform_data/cros_ec_commands.h #262

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

2690 struct ec_response_motion_sense {
2691         union {
2692                 /* Used for MOTIONSENSE_CMD_DUMP */
2693                 struct __ec_todo_unpacked {
2694                         /* Flags representing the motion sensor module. */
2695                         uint8_t module_flags;
2696 
2697                         /* Number of sensors managed directly by the EC. */
2698                         uint8_t sensor_count;
2699 
2700                         /*
2701                          * Sensor data is truncated if response_max is too small
2702                          * for holding all the data.
2703                          */
2704                         struct ec_response_motion_sensor_data sensor[0];
2705                 } dump;
...

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

drivers/iio/accel/cros_ec_accel_legacy.c:66:46: warning: array subscript <unknown> is outside array bounds ofstruct ec_response_motion_sensor_data[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
@GustavoARSilva GustavoARSilva added the [PATCH] Exists A patch exists to address the issue label Feb 24, 2023
@GustavoARSilva
Copy link
Collaborator Author

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.

Use the DECLARE_FLEX_ARRAY() helper macro to transform zero-length
arrays in unions with flexible-array members.

Address the following warning found with GCC-13 and
-fstrict-flex-arrays=3 enabled:
drivers/iio/accel/cros_ec_accel_legacy.c:66:46: warning: array subscript <unknown> is outside array bounds of ‘struct ec_response_motion_sensor_data[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#193
Link: KSPP#262
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
jessfraz pushed a commit to jessfraz/linux that referenced this issue Mar 9, 2023
Zero-length arrays as fake flexible arrays are deprecated and we are
moving towards adopting C99 flexible-array members instead.

Use the DECLARE_FLEX_ARRAY() helper macro to transform zero-length
arrays in unions with flexible-array members.

Address the following warning found with GCC-13 and
-fstrict-flex-arrays=3 enabled:
drivers/iio/accel/cros_ec_accel_legacy.c:66:46: warning: array subscript <unknown> is outside array bounds of ‘struct ec_response_motion_sensor_data[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#193
Link: KSPP/linux#262
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/ZAZUGBmSLc5wg7AK@work
1054009064 pushed a commit to 1054009064/linux that referenced this issue Apr 24, 2023
Zero-length arrays as fake flexible arrays are deprecated and we are
moving towards adopting C99 flexible-array members instead.

Use the DECLARE_FLEX_ARRAY() helper macro to transform zero-length
arrays in unions with flexible-array members.

Address the following warning found with GCC-13 and
-fstrict-flex-arrays=3 enabled:
drivers/iio/accel/cros_ec_accel_legacy.c:66:46: warning: array subscript <unknown> is outside array bounds of ‘struct ec_response_motion_sensor_data[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#193
Link: KSPP#262
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/ZAZUGBmSLc5wg7AK@work
@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