staging: r8188eu: Use the ARRAY_SIZE() macro
authorFabio M. De Francesco <fmdefrancesco@gmail.com>
Sat, 2 Apr 2022 16:34:39 +0000 (18:34 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 4 Apr 2022 05:33:49 +0000 (07:33 +0200)
Use the ARRAY_SIZE() macro in places where there are open coded
calculations of the size of arrays.

ARRAY_SIZE(arr) makes sure that "arr" is an array, it's safer than
sizeof(arr) / sizeof(arr[0]), and improves readibility.

Detected with the help of Coccinelle.

Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Link: https://lore.kernel.org/r/20220402163439.20457-1-fmdefrancesco@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/core/rtw_mlme_ext.c
drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c
drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c
drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c
drivers/staging/r8188eu/os_dep/ioctl_linux.c

index 6166baa64091c82a552de2224daafec337f115b6..be81a01e5fb8d495902f9ca402d7c4f7c33ac535 100644 (file)
@@ -3981,7 +3981,7 @@ unsigned int OnAction(struct adapter *padapter, struct recv_frame *precv_frame)
 
        category = frame_body[0];
 
-       for (i = 0; i < sizeof(OnAction_tbl) / sizeof(struct action_handler); i++) {
+       for (i = 0; i < ARRAY_SIZE(OnAction_tbl); i++) {
                ptable = &OnAction_tbl[i];
                if (category == ptable->num)
                        ptable->func(padapter, precv_frame);
index e7f834b02567bf9fa78681051d91a4a8bc0572ad..7901d0afa2e772134769e44ccc3142f681a8562b 100644 (file)
@@ -170,7 +170,7 @@ enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm)
 {
        u32     hex         = 0;
        u32     i           = 0;
-       u32     arraylen    = sizeof(array_agc_tab_1t_8188e) / sizeof(u32);
+       u32     arraylen    = ARRAY_SIZE(array_agc_tab_1t_8188e);
        u32    *array       = array_agc_tab_1t_8188e;
        bool            biol = false;
        struct adapter *adapter =  dm_odm->Adapter;
@@ -446,7 +446,7 @@ enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm)
 {
        u32     hex         = 0;
        u32     i           = 0;
-       u32     arraylen    = sizeof(array_phy_reg_1t_8188e) / sizeof(u32);
+       u32     arraylen    = ARRAY_SIZE(array_phy_reg_1t_8188e);
        u32    *array       = array_phy_reg_1t_8188e;
        bool    biol = false;
        struct adapter *adapter =  dm_odm->Adapter;
@@ -651,7 +651,7 @@ void ODM_ReadAndConfig_PHY_REG_PG_8188E(struct odm_dm_struct *dm_odm)
 {
        u32  hex;
        u32  i           = 0;
-       u32  arraylen    = sizeof(array_phy_reg_pg_8188e) / sizeof(u32);
+       u32  arraylen    = ARRAY_SIZE(array_phy_reg_pg_8188e);
        u32 *array       = array_phy_reg_pg_8188e;
 
        hex = ODM_ITRF_USB << 8;
index 20ce1571fc26fec7927a095a3d33c7a6b96918de..77b25885c63b718ac7d2e4c4e27673db90c69371 100644 (file)
@@ -132,7 +132,7 @@ enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm)
 
        u32     hex         = 0;
        u32     i;
-       u32     array_len    = sizeof(array_MAC_REG_8188E) / sizeof(u32);
+       u32     array_len    = ARRAY_SIZE(array_MAC_REG_8188E);
        u32    *array       = array_MAC_REG_8188E;
        bool    biol = false;
 
index 9dc888a66d092bbbb35d924eba383ceac58ba740..08cbfce3808de2be44ebaeb622ce27c993157e54 100644 (file)
@@ -138,7 +138,7 @@ enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm)
 
        u32     hex         = 0;
        u32     i           = 0;
-       u32     ArrayLen    = sizeof(Array_RadioA_1T_8188E) / sizeof(u32);
+       u32     ArrayLen    = ARRAY_SIZE(Array_RadioA_1T_8188E);
        u32    *Array       = Array_RadioA_1T_8188E;
        bool            biol = false;
        struct adapter *Adapter =  pDM_Odm->Adapter;
index 6383b399ae40d423dba270e955ba0aa86dfb535b..d127cebb6eaead3c22413e677aadc57564711015 100644 (file)
@@ -3949,10 +3949,10 @@ static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev)
 
 struct iw_handler_def rtw_handlers_def = {
        .standard = rtw_handlers,
-       .num_standard = sizeof(rtw_handlers) / sizeof(iw_handler),
+       .num_standard = ARRAY_SIZE(rtw_handlers),
        .private = rtw_private_handler,
        .private_args = (struct iw_priv_args *)rtw_private_args,
-       .num_private = sizeof(rtw_private_handler) / sizeof(iw_handler),
-       .num_private_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args),
+       .num_private = ARRAY_SIZE(rtw_private_handler),
+       .num_private_args = ARRAY_SIZE(rtw_private_args),
        .get_wireless_stats = rtw_get_wireless_stats,
 };