Linux-fbdev Archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: fbtft: Use ARRAY_SIZE() to get argument count
@ 2022-10-28 13:30 Deepak R Varma
  2022-10-29  7:32 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 12+ messages in thread
From: Deepak R Varma @ 2022-10-28 13:30 UTC (permalink / raw)
  To: outreachy, Greg Kroah-Hartman, dri-devel, linux-fbdev,
	linux-staging, linux-kernel

The ARRAY_SIZE(foo) macro should be preferred over sizeof operator
based computation such as sizeof(foo)/sizeof(foo[0]) for finding
number of elements in an array. Issue identified using coccicheck.

Signed-off-by: Deepak R Varma <drv@mailo.com>
---
 drivers/staging/fbtft/fbtft.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h
index 2c2b5f1c1df3..5506a473be91 100644
--- a/drivers/staging/fbtft/fbtft.h
+++ b/drivers/staging/fbtft/fbtft.h
@@ -231,7 +231,7 @@ struct fbtft_par {
 	bool polarity;
 };

-#define NUMARGS(...)  (sizeof((int[]){__VA_ARGS__}) / sizeof(int))
+#define NUMARGS(...)  ARRAY_SIZE(((int[]){ __VA_ARGS__ }))

 #define write_reg(par, ...)                                            \
 	((par)->fbtftops.write_register(par, NUMARGS(__VA_ARGS__), __VA_ARGS__))
--
2.34.1




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

end of thread, other threads:[~2022-11-09 16:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-28 13:30 [PATCH] staging: fbtft: Use ARRAY_SIZE() to get argument count Deepak R Varma
2022-10-29  7:32 ` Greg Kroah-Hartman
2022-10-29 16:58   ` Deepak R Varma
2022-10-29 17:34     ` Julia Lawall
2022-10-31  7:11       ` Deepak R Varma
2022-10-31  9:40         ` Deepak R Varma
2022-10-31  9:41           ` Deepak R Varma
2022-10-31 12:05           ` Julia Lawall
2022-11-04 12:01             ` Deepak R Varma
2022-11-04 14:42               ` Deepak R Varma
2022-11-09 15:00                 ` Deepak R Varma
2022-11-09 16:00                   ` Greg Kroah-Hartman

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 read-only IMAP folder(s) and NNTP newsgroup(s).