On 2/11/21 05:06, Dan Carpenter wrote: > On Wed, Feb 10, 2021 at 04:49:37PM -0600, Gustavo A. R. Silva wrote: >> There is a regular need in the kernel to provide a way to declare having >> a dynamically sized set of trailing elements in a structure. Kernel code >> should always use “flexible array members”[1] for these cases. The older >> style of one-element or zero-length arrays should no longer be used[2]. >> >> Refactor the code according to the use of a flexible-array member in >> struct ndis_80211_var_ie, instead of a one-element array. >> >> Also, this helps with the ongoing efforts to enable -Warray-bounds and >> fix the following warnings: >> >> CC [M] drivers/staging/rtl8723bs/core/rtw_wlan_util.o >> In file included from ./drivers/staging/rtl8723bs/include/drv_types.h:20, >> from drivers/staging/rtl8723bs/core/rtw_wlan_util.c:9: >> drivers/staging/rtl8723bs/core/rtw_wlan_util.c: In function >> ‘HT_caps_handler’: >> ./drivers/staging/rtl8723bs/include/basic_types.h:108:11: warning: array >> subscript 1 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} >> [-Warray-bounds] >> 108 | (EF1BYTE(*((u8 *)(__pstart)))) >> | ^ >> ./drivers/staging/rtl8723bs/include/basic_types.h:42:8: note: in definition >> of macro ‘EF1BYTE’ >> 42 | ((u8)(_val)) >> | ^~~~ >> ./drivers/staging/rtl8723bs/include/basic_types.h:127:4: note: in expansion >> of macro ‘LE_P1BYTE_TO_HOST_1BYTE’ >> 127 | (LE_P1BYTE_TO_HOST_1BYTE(__pstart) >> (__bitoffset)) & \ >> | ^~~~~~~~~~~~~~~~~~~~~~~ >> ./drivers/staging/rtl8723bs/include/rtw_ht.h:97:55: note: in expansion of >> macro ‘LE_BITS_TO_1BYTE’ >> 97 | #define GET_HT_CAPABILITY_ELE_RX_STBC(_pEleStart) >> LE_BITS_TO_1BYTE((_pEleStart)+1, 0, 2) >> | >> ^~~~~~~~~~~~~~~~ >> drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1104:58: note: in expansion >> of macro ‘GET_HT_CAPABILITY_ELE_RX_STBC’ >> 1104 | if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX) && >> GET_HT_CAPABILITY_ELE_RX_STBC(pIE->data)) { >> | >> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1051:75: warning: array >> subscript 2 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} >> [-Warray-bounds] >> 1051 | if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3) > >> (pIE->data[i] & 0x3)) >> | >> ~~~~~~~~~^~~ >> drivers/staging/rtl8723bs/core/rtw_wlan_util.c: In function ‘check_assoc_AP’: >> drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1606:19: warning: array >> subscript 4 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} >> [-Warray-bounds] >> 1606 | if (pIE->data[4] == 1) >> | ~~~~~~~~~^~~ >> drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1609:20: warning: array >> subscript 5 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} >> [-Warray-bounds] >> 1609 | if (pIE->data[5] & RT_HT_CAP_USE_92SE) >> | ~~~~~~~~~^~~ >> drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1613:19: warning: array >> subscript 5 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} >> [-Warray-bounds] >> 1613 | if (pIE->data[5] & RT_HT_CAP_USE_SOFTAP) >> | ~~~~~~~~~^~~ >> drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1617:20: warning: array >> subscript 6 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} >> [-Warray-bounds] >> 1617 | if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_BCUT) { >> | ~~~~~~~~~^~~ >> >> [1] https://en.wikipedia.org/wiki/Flexible_array_member >> [2] >> https://www.kernel.org/doc/html/v5.9/process/deprecated.html#zero-length-and-one-element-arrays >> >> Link: https://github.com/KSPP/linux/issues/79 >> Link: https://github.com/KSPP/linux/issues/109 >> Build-tested-by: kernel test robot <l...@intel.com> >> Link: https://lore.kernel.org/lkml/602434b8.jc5doxj0bmhoxgil%25...@intel.com/ >> Signed-off-by: Gustavo A. R. Silva <gustavo...@kernel.org> > > Looks okay to me. I looked for potential issues with changing the > sizeof the struct but couldn't find any.
Great. Yeah; that's one of the first things I look at when I make these changes. Thanks for double checking. :) > Reviewed-by: Dan Carpenter <dan.carpen...@oracle.com> Thanks! -- Gustavo _______________________________________________ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel