mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-14 18:29:12 +08:00
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 <fmdefrancesco@gmail.com> Link: https://lore.kernel.org/r/20220402163439.20457-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
28f7545d9f
commit
c9736770e6
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user