diff options
author | Jérémy Lefaure | 2017-10-01 21:30:55 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2017-10-03 18:34:57 +0200 |
commit | 60db8d10ee3339840d88e57605276bb568af6031 (patch) | |
tree | e5093170ab3ac17a0745a1c282a2ac1c2e82d27c /drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | |
parent | staging: rtlwifi: use ARRAY_SIZE (diff) | |
download | kernel-qcow2-linux-60db8d10ee3339840d88e57605276bb568af6031.tar.gz kernel-qcow2-linux-60db8d10ee3339840d88e57605276bb568af6031.tar.xz kernel-qcow2-linux-60db8d10ee3339840d88e57605276bb568af6031.zip |
staging: rtl8723bs: use ARRAY_SIZE
Using the ARRAY_SIZE macro improves the readability of the code. Also,
it is not always useful to use a variable to store this constant
calculated at compile time.
Found with Coccinelle with the following semantic patch:
@r depends on (org || report)@
type T;
T[] E;
position p;
@@
(
(sizeof(E)@p /sizeof(*E))
|
(sizeof(E)@p /sizeof(E[...]))
|
(sizeof(E)@p /sizeof(T))
)
Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/rtl8723bs/os_dep/ioctl_linux.c')
-rw-r--r-- | drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 6a8f805c0b28..3fca0c2d4c8d 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -18,6 +18,7 @@ #include <rtw_debug.h> #include <rtw_mp.h> #include <linux/jiffies.h> +#include <linux/kernel.h> #define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV+30) @@ -5017,12 +5018,12 @@ 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), #if defined(CONFIG_WEXT_PRIV) .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), #endif .get_wireless_stats = rtw_get_wireless_stats, }; @@ -5109,8 +5110,8 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ priv = rtw_private_handler; priv_args = rtw_private_args; - num_priv = sizeof(rtw_private_handler) / sizeof(iw_handler); - num_priv_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args); + num_priv = ARRAY_SIZE(rtw_private_handler); + num_priv_args = ARRAY_SIZE(rtw_private_args); if (num_priv_args == 0) { err = -EOPNOTSUPP; |