* [PATCH] staging: r8188eu: fix array_size.cocci warning
@ 2021-11-16 6:41 Guo Zhengkui
2021-11-16 6:41 ` Guo Zhengkui
2021-11-16 6:54 ` Pavel Skripkin
0 siblings, 2 replies; 3+ messages in thread
From: Guo Zhengkui @ 2021-11-16 6:41 UTC (permalink / raw)
To: Larry Finger, Phillip Potter, Greg Kroah-Hartman, Guo Zhengkui,
Michael Straube, open list:STAGING SUBSYSTEM, open list
Cc: kernel
Fix following array_size.cocci warning:
./drivers/staging/r8188eu/core/rtw_rf.c:38:48-49: WARNING: Use ARRAY_SIZE.
ARRAY_SIZE() defined in <linux/kernel.h> is safer because it uses
__must_be_array().
Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
---
drivers/staging/r8188eu/core/rtw_rf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/r8188eu/core/rtw_rf.c b/drivers/staging/r8188eu/core/rtw_rf.c
index 2ec56012516e..e704092d31d0 100644
--- a/drivers/staging/r8188eu/core/rtw_rf.c
+++ b/drivers/staging/r8188eu/core/rtw_rf.c
@@ -35,7 +35,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)
{
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] staging: r8188eu: fix array_size.cocci warning
2021-11-16 6:41 [PATCH] staging: r8188eu: fix array_size.cocci warning Guo Zhengkui
@ 2021-11-16 6:41 ` Guo Zhengkui
2021-11-16 6:54 ` Pavel Skripkin
1 sibling, 0 replies; 3+ messages in thread
From: Guo Zhengkui @ 2021-11-16 6:41 UTC (permalink / raw)
To: Larry Finger, Phillip Potter, Greg Kroah-Hartman, Guo Zhengkui,
Michael Straube, open list:STAGING SUBSYSTEM, open list
Cc: kernel
Fix following array_size.cocci warning:
./drivers/staging/r8188eu/core/rtw_rf.c:38:48-49: WARNING: Use ARRAY_SIZE.
ARRAY_SIZE() defined in <linux/kernel.h> is safer because it uses
__must_be_array().
Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
---
drivers/staging/r8188eu/core/rtw_rf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/r8188eu/core/rtw_rf.c b/drivers/staging/r8188eu/core/rtw_rf.c
index 2ec56012516e..e704092d31d0 100644
--- a/drivers/staging/r8188eu/core/rtw_rf.c
+++ b/drivers/staging/r8188eu/core/rtw_rf.c
@@ -35,7 +35,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)
{
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: r8188eu: fix array_size.cocci warning
2021-11-16 6:41 [PATCH] staging: r8188eu: fix array_size.cocci warning Guo Zhengkui
2021-11-16 6:41 ` Guo Zhengkui
@ 2021-11-16 6:54 ` Pavel Skripkin
1 sibling, 0 replies; 3+ messages in thread
From: Pavel Skripkin @ 2021-11-16 6:54 UTC (permalink / raw)
To: Guo Zhengkui, Larry Finger, Phillip Potter, Greg Kroah-Hartman,
Michael Straube, open list:STAGING SUBSYSTEM, open list
Cc: kernel
On 11/16/21 09:41, Guo Zhengkui wrote:
> diff --git a/drivers/staging/r8188eu/core/rtw_rf.c b/drivers/staging/r8188eu/core/rtw_rf.c
> index 2ec56012516e..e704092d31d0 100644
> --- a/drivers/staging/r8188eu/core/rtw_rf.c
> +++ b/drivers/staging/r8188eu/core/rtw_rf.c
> @@ -35,7 +35,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)
> {
>
Hm, do we need this variable to be static? It's used only in 2
expressions in rtw_ch2freq() (and 2nd one can be removed by
per-initializing freq with 2412).
I think, it can be places on stack to reduce binary size.
With regards,
Pavel Skripkin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-16 6:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 6:41 [PATCH] staging: r8188eu: fix array_size.cocci warning Guo Zhengkui
2021-11-16 6:41 ` Guo Zhengkui
2021-11-16 6:54 ` Pavel Skripkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).