From: Joyeta Modak <joyetamdk@gmail.com>
To: andy@kernel.org, gregkh@linuxfoundation.org
Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Joyeta Modak <joyetamdk@gmail.com>
Subject: [PATCH] staging: fbtft: use ARRAY_SIZE() in NUMARGS macro
Date: Wed, 24 Jun 2026 13:08:04 +0530 [thread overview]
Message-ID: <20260624073804.4391-1-joyetamdk@gmail.com> (raw)
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
next reply other threads:[~2026-06-24 7:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-24 7:38 Joyeta Modak [this message]
2026-06-24 11:31 ` [PATCH] staging: fbtft: use ARRAY_SIZE() in NUMARGS macro Andy Shevchenko
2026-06-24 13:02 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260624073804.4391-1-joyetamdk@gmail.com \
--to=joyetamdk@gmail.com \
--cc=andy@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.