]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform/chrome: Replace fake flexible arrays with flexible-array member
authorGustavo A. R. Silva <gustavoars@kernel.org>
Mon, 6 Mar 2023 20:59:04 +0000 (14:59 -0600)
committerTzung-Bi Shih <tzungbi@kernel.org>
Mon, 24 Apr 2023 05:35:11 +0000 (13:35 +0800)
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: https://github.com/KSPP/linux/issues/21
Link: https://github.com/KSPP/linux/issues/193
Link: https://github.com/KSPP/linux/issues/262
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html
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
include/linux/platform_data/cros_ec_commands.h

index 7e9c76aedd2dd6022931a2ae6f110a1f6f1b340e..ab721cf13a9864c9e4d1fa54218686d9cadcd0e7 100644 (file)
@@ -2701,7 +2701,7 @@ struct ec_response_motion_sense {
                         * Sensor data is truncated if response_max is too small
                         * for holding all the data.
                         */
-                       struct ec_response_motion_sensor_data sensor[0];
+                       DECLARE_FLEX_ARRAY(struct ec_response_motion_sensor_data, sensor);
                } dump;
 
                /* Used for MOTIONSENSE_CMD_INFO. */