* [PATCH] staging: fbtft: use ARRAY_SIZE() in NUMARGS macro
@ 2026-06-24 7:38 Joyeta Modak
0 siblings, 0 replies; only message in thread
From: Joyeta Modak @ 2026-06-24 7:38 UTC (permalink / raw)
To: andy, gregkh
Cc: dri-devel, linux-fbdev, linux-staging, linux-kernel, Joyeta Modak
NUMARGS() computes the number of arguments by dividing the size of a
temporary int array by sizeof(int). Using the standard ARRAY_SIZE()
macro is the correct way to count array elements in the kernel, and
ARRAY_SIZE() also provides a __must_be_array() compile time check. There
are no functional changes.
Found using make coccicheck (scripts/coccinelle/misc/array_size.cocci).
Signed-off-by: Joyeta Modak <joyetamdk@gmail.com>
---
drivers/staging/fbtft/fbtft.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h
index c7afb0fd3..48da1503f 100644
--- a/drivers/staging/fbtft/fbtft.h
+++ b/drivers/staging/fbtft/fbtft.h
@@ -4,6 +4,7 @@
#ifndef __LINUX_FBTFT_H
#define __LINUX_FBTFT_H
+#include <linux/array_size.h>
#include <linux/fb.h>
#include <linux/spinlock.h>
#include <linux/spi/spi.h>
@@ -233,7 +234,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.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-24 7:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24 7:38 [PATCH] staging: fbtft: use ARRAY_SIZE() in NUMARGS macro Joyeta Modak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox