staging: r8188eu: Use the ARRAY_SIZE() macro
PATCH 1/1 staging: r8188eu: Use the ARRAY_SIZE() macro
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 <[email protected]>
--- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 2 +- drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c | 6 +++--- drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c | 2 +- drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c | 2 +- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-)
drivers/staging/r8188eu/core/rtw_mlme_ext.c +1 -1
@@ -3985,7 +3985,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);
drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c +3 -3
@@ -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 ;
drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c +1 -1
@@ -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;
drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c +1 -1
@@ -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;
drivers/staging/r8188eu/os_dep/ioctl_linux.c +3 -3
@@ -3958,10 +3958,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, };
Signature · 1 line
2.34.1