Use ARRAY_SIZE macro
Subsystems (2)
cover Use ARRAY_SIZE macro
Use ARRAY_SIZE macro.
Coccinelle is used to make the changes-
@@
type T;
T[] E;
@@
- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
Shraddha Barke (3):
Staging: sm750fb: Use ARRAY_SIZE macro
Staging: rtl8712: Use ARRAY_SIZE macro
Staging: rtl8188eu: core: Use ARRAY_SIZE macro
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8188eu/core/rtw_rf.c | 2 +- drivers/staging/rtl8712/usb_intf.c | 3 +-- drivers/staging/sm750fb/ddk750_chip.c | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/3 Staging: sm750fb: Use ARRAY_SIZE macro
ARRAY_SIZE is more concise to use when the size of an array is divided by the size of its first element.
Changes made using Coccinelle-
@@
type T;
T[] E;
@@
- (sizeof(E)/sizeof(E[...]))
+ ARRAY_SIZE(E)
--- drivers/staging/sm750fb/ddk750_chip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/sm750fb/ddk750_chip.c +2 -2
@@ -384,10 +384,10 @@ unsigned int calcPllValue(unsigned int request_orig, pll_value_t *pll)if (pll->clockType !=MXCLK_PLL ) { xparm = &xparm_PIXEL[0 ]; - xcnt =sizeof (xparm_PIXEL) /sizeof (xparm_PIXEL[0 ]); + xcnt =ARRAY_SIZE (xparm_PIXEL); }else { xparm = &xparm_MXCLK[0 ]; - xcnt =sizeof (xparm_MXCLK) /sizeof (xparm_MXCLK[0 ]); + xcnt =ARRAY_SIZE (xparm_MXCLK); }
Signature · 1 line
2.1.4
PATCH 2/3 Staging: rtl8712: Use ARRAY_SIZE macro
In reply to Shraddha BarkeARRAY_SIZE is more concise to use when the size of an array is divided by the size of its type
Changes made using Coccinelle-
@@
type T;
T[] E;
@@
- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
--- drivers/staging/rtl8712/usb_intf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8712/usb_intf.c +1 -2
@@ -330,8 +330,7 @@ static void disable_ht_for_spec_devid(const struct usb_device_id *pdid,u16 vid, pid;u32 flags;int i; -int num =sizeof (specific_device_id_tbl) / -sizeof (struct specific_device_id ); +int num =ARRAY_SIZE (specific_device_id_tbl);for (i =0 ; i < num; i++) { vid = specific_device_id_tbl[i].idVendor;
Signature · 1 line
2.1.4
PATCH 3/3 Staging: rtl8188eu: core: Use ARRAY_SIZE macro
In reply to Shraddha BarkeARRAY_SIZE is more concise to use when the size of an array is divided by the size of its type.
Changes made using Coccinelle-
@@
type T;
T[] E;
@@
- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
--- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8188eu/core/rtw_rf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +1 -1
@@ -3926,7 +3926,7 @@ static unsigned int OnAction(struct adapter *padapter, 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/rtl8188eu/core/rtw_rf.c +1 -1
@@ -52,7 +52,7 @@ static struct ch_freq ch_freq_map[] = { {216, 5080},/* Japan, means J16 */ }; -static int ch_freq_map_num = (sizeof (ch_freq_map) /sizeof (struct ch_freq )); +static int ch_freq_map_num =ARRAY_SIZE (ch_freq_map);u32 rtw_ch2freq (u32 channel) {
Signature · 1 line
2.1.4