All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next] staging: r8188eu: use ARRAY_SIZE
@ 2021-09-16  1:59 CGEL
  2021-09-16 12:42 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: CGEL @ 2021-09-16  1:59 UTC (permalink / raw)
  To: Larry Finger
  Cc: Phillip Potter, Greg Kroah-Hartman, Michael Straube,
	Martin Kaiser, Nathan Chancellor, linux-staging, linux-kernel,
	Changcheng Deng, Zeal Robot

From: Changcheng Deng <deng.changcheng@zte.com.cn>

Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
---
 drivers/staging/r8188eu/os_dep/usb_intf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c
index 78c857d..c7de8ee 100644
--- a/drivers/staging/r8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/r8188eu/os_dep/usb_intf.c
@@ -261,8 +261,7 @@ static void process_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;
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH linux-next] staging: r8188eu: use ARRAY_SIZE
  2021-09-16  1:59 [PATCH linux-next] staging: r8188eu: use ARRAY_SIZE CGEL
@ 2021-09-16 12:42 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2021-09-16 12:42 UTC (permalink / raw)
  To: CGEL
  Cc: Larry Finger, Phillip Potter, Greg Kroah-Hartman,
	Michael Straube, Martin Kaiser, Nathan Chancellor, linux-staging,
	linux-kernel, Changcheng Deng, Zeal Robot

On Thu, Sep 16, 2021 at 01:59:36AM +0000, CGEL wrote:
> From: Changcheng Deng <deng.changcheng@zte.com.cn>
> 
> Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
> ---
>  drivers/staging/r8188eu/os_dep/usb_intf.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c
> index 78c857d..c7de8ee 100644
> --- a/drivers/staging/r8188eu/os_dep/usb_intf.c
> +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c
> @@ -261,8 +261,7 @@ static void process_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++) {

Get rid of the "num" variable and use ARRAY_SIZE() directly.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-16 12:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16  1:59 [PATCH linux-next] staging: r8188eu: use ARRAY_SIZE CGEL
2021-09-16 12:42 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.