]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtlwifi: Replace fake flex-array with flex-array member
authorGustavo A. R. Silva <gustavoars@kernel.org>
Fri, 24 Mar 2023 01:11:35 +0000 (19:11 -0600)
committerKalle Valo <kvalo@kernel.org>
Fri, 31 Mar 2023 14:49:40 +0000 (17:49 +0300)
Zero-length arrays as fake flexible arrays are deprecated and we are
moving towards adopting C99 flexible-array members instead.

Address the following warning found with GCC-13 and
-fstrict-flex-arrays=3 enabled:
In function ‘fortify_memset_chk’,
    inlined from ‘rtl_usb_probe’ at drivers/net/wireless/realtek/rtlwifi/usb.c:1044:2:
./include/linux/fortify-string.h:430:25: warning: call to ‘__write_overflow_field’ declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Wattribute-warning]
  430 |                         __write_overflow_field(p_size_field, size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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/277
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/ZBz4x+MWoI/f65o1@work
drivers/net/wireless/realtek/rtlwifi/wifi.h

index 31f9e9e5c68042f2134f71c9026ec659d64e7832..082af216760f8e5aadc84b7dddfc6afc216748e4 100644 (file)
@@ -2831,7 +2831,7 @@ struct rtl_priv {
         * beyond  this structure like:
         * rtl_pci_priv or rtl_usb_priv
         */
-       u8 priv[0] __aligned(sizeof(void *));
+       u8 priv[] __aligned(sizeof(void *));
 };
 
 #define rtl_priv(hw)           (((struct rtl_priv *)(hw)->priv))