From: Florian Bezdeka <florian.bezdeka@siemens.com>
To: jan.kiszka@siemens.com, xenomai@lists.linux.dev
Cc: Florian Bezdeka <florian.bezdeka@siemens.com>
Subject: [PATCH 03/13] lib: Migrate to ARRAY_SIZE()
Date: Tue, 05 Dec 2023 13:41:40 +0100 [thread overview]
Message-ID: <20231201-flo-array-size-v1-3-3e0abd7c68fa@siemens.com> (raw)
In-Reply-To: <20231201-flo-array-size-v1-0-3e0abd7c68fa@siemens.com>
Use ARRAY_SIZE() where possible. No functional change.
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
lib/boilerplate/ancillaries.c | 4 ++--
lib/boilerplate/setup.c | 2 +-
lib/cobalt/mutex.c | 2 +-
lib/cobalt/sigshadow.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/boilerplate/ancillaries.c b/lib/boilerplate/ancillaries.c
index a0754cb48..457ef0b7c 100644
--- a/lib/boilerplate/ancillaries.c
+++ b/lib/boilerplate/ancillaries.c
@@ -182,7 +182,7 @@ static const char *__esym_map[] = {
__esym_def(EPROTO),
};
-#define __esym_max (sizeof(__esym_map) / sizeof(__esym_map[0]))
+#define __esym_max ARRAY_SIZE(__esym_map)
const char *symerror(int errnum)
{
@@ -472,7 +472,7 @@ char *lookup_command(const char *cmd)
char *path;
int n, ret;
- for (n = 0; n < sizeof(dirs) / sizeof(dirs[0]); n++) {
+ for (n = 0; n < ARRAY_SIZE(dirs); n++) {
ret = asprintf(&path, "%s/%s", dirs[n], cmd);
if (ret < 0)
return NULL;
diff --git a/lib/boilerplate/setup.c b/lib/boilerplate/setup.c
index 5139560e8..a9138e96b 100644
--- a/lib/boilerplate/setup.c
+++ b/lib/boilerplate/setup.c
@@ -304,7 +304,7 @@ static struct option *build_option_array(int *base_opt_startp)
const struct option *p;
int nopts;
- nopts = sizeof(base_options) / sizeof(base_options[0]);
+ nopts = ARRAY_SIZE(base_options);
if (!pvlist_empty(&setup_list)) {
pvlist_for_each_entry(setup, &setup_list, __reserved.next) {
diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index 54f6b8461..c77d10684 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -196,7 +196,7 @@ static int __attribute__((cold))
};
int i;
- for (i = sizeof(mutex_types) / sizeof(mutex_types[0]); i > 0; --i) {
+ for (i = ARRAY_SIZE(mutex_types); i > 0; --i) {
if (memcmp(mutex, &mutex_initializers[i - 1],
sizeof(mutex_initializers[0])) == 0)
return mutex_types[i - 1];
diff --git a/lib/cobalt/sigshadow.c b/lib/cobalt/sigshadow.c
index b03703526..092cadb08 100644
--- a/lib/cobalt/sigshadow.c
+++ b/lib/cobalt/sigshadow.c
@@ -53,7 +53,7 @@ int cobalt_sigshadow_handler(int sig, siginfo_t *si, void *ctxt)
break;
case SIGSHADOW_ACTION_BACKTRACE:
arg = sigshadow_arg(si->si_int);
- nr = backtrace(frames, sizeof(frames) / sizeof(frames[0]));
+ nr = backtrace(frames, ARRAY_SIZE(frames));
/* Skip the sighandler context. */
skip = nr > 3 ? 3 : 0;
XENOMAI_SYSCALL3(sc_cobalt_backtrace, nr - skip, frames + skip, arg);
--
2.39.2
next prev parent reply other threads:[~2023-12-05 12:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-05 12:41 [PATCH 00/13] Migration to ARRAY_SIZE() and further include cleanups Florian Bezdeka
2023-12-05 12:41 ` [PATCH 01/13] testsuite: Migrate to ARRAY_SIZE() Florian Bezdeka
2023-12-05 12:41 ` [PATCH 02/13] demo: " Florian Bezdeka
2023-12-05 12:41 ` Florian Bezdeka [this message]
2023-12-05 12:41 ` [PATCH 04/13] kernel/drivers: Mirate " Florian Bezdeka
2023-12-05 12:41 ` [PATCH 05/13] demo: Cleanup includes Florian Bezdeka
2023-12-05 12:41 ` [PATCH 06/13] lib/alchemy: " Florian Bezdeka
2023-12-05 12:41 ` [PATCH 07/13] lib/analogy: " Florian Bezdeka
2023-12-05 12:41 ` [PATCH 08/13] lib/boilerplate: " Florian Bezdeka
2023-12-05 12:41 ` [PATCH 09/13] lib/copperplate: " Florian Bezdeka
2023-12-05 12:41 ` [PATCH 10/13] lib/psos: " Florian Bezdeka
2023-12-05 12:41 ` [PATCH 11/13] lib/smokey: " Florian Bezdeka
2023-12-05 12:41 ` [PATCH 12/13] lib/trank: " Florian Bezdeka
2023-12-05 12:41 ` [PATCH 13/13] lib/vxworks: " Florian Bezdeka
2023-12-07 2:37 ` [PATCH 00/13] Migration to ARRAY_SIZE() and further include cleanups Jan Kiszka
2023-12-07 9:13 ` Jan Kiszka
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=20231201-flo-array-size-v1-3-3e0abd7c68fa@siemens.com \
--to=florian.bezdeka@siemens.com \
--cc=jan.kiszka@siemens.com \
--cc=xenomai@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.