All of lore.kernel.org
 help / color / mirror / Atom feed
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 02/13] demo: Migrate to ARRAY_SIZE()
Date: Tue, 05 Dec 2023 13:41:39 +0100	[thread overview]
Message-ID: <20231201-flo-array-size-v1-2-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>
---
 demo/posix/cobalt/bufp-label.c     | 4 +++-
 demo/posix/cobalt/bufp-readwrite.c | 4 +++-
 demo/posix/cobalt/iddp-label.c     | 4 +++-
 demo/posix/cobalt/iddp-sendrecv.c  | 4 +++-
 demo/posix/cobalt/xddp-echo.c      | 4 +++-
 demo/posix/cobalt/xddp-label.c     | 4 +++-
 demo/posix/cobalt/xddp-stream.c    | 4 +++-
 demo/posix/cyclictest/cyclictest.c | 6 +++---
 8 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/demo/posix/cobalt/bufp-label.c b/demo/posix/cobalt/bufp-label.c
index 1141c8913..85984c7c7 100644
--- a/demo/posix/cobalt/bufp-label.c
+++ b/demo/posix/cobalt/bufp-label.c
@@ -30,6 +30,8 @@
 #include <string.h>
 #include <pthread.h>
 #include <errno.h>
+
+#include <boilerplate/ancillaries.h>
 #include <rtdm/ipc.h>
 
 pthread_t svtid, cltid;
@@ -163,7 +165,7 @@ static void *client(void *arg)
 		}
 		printf("%s: sent %d bytes, \"%.*s\"\n",
 		       __FUNCTION__, ret, ret, msg[n]);
-		n = (n + 1) % (sizeof(msg) / sizeof(msg[0]));
+		n = (n + 1) % ARRAY_SIZE(msg);
 		/*
 		 * We run in full real-time mode (i.e. primary mode),
 		 * so we have to let the system breathe between two
diff --git a/demo/posix/cobalt/bufp-readwrite.c b/demo/posix/cobalt/bufp-readwrite.c
index 34d761aeb..74faa5bc8 100644
--- a/demo/posix/cobalt/bufp-readwrite.c
+++ b/demo/posix/cobalt/bufp-readwrite.c
@@ -30,6 +30,8 @@
 #include <string.h>
 #include <pthread.h>
 #include <errno.h>
+
+#include <boilerplate/ancillaries.h>
 #include <rtdm/ipc.h>
 
 pthread_t svtid, cltid;
@@ -128,7 +130,7 @@ static void *client(void *arg)
 		}
 		printf("%s: sent %d bytes, \"%.*s\"\n",
 		       __FUNCTION__, ret, ret, msg[n]);
-		n = (n + 1) % (sizeof(msg) / sizeof(msg[0]));
+		n = (n + 1) % ARRAY_SIZE(msg);
 		/*
 		 * We run in full real-time mode (i.e. primary mode),
 		 * so we have to let the system breathe between two
diff --git a/demo/posix/cobalt/iddp-label.c b/demo/posix/cobalt/iddp-label.c
index 06fc8814c..fe21bf77f 100644
--- a/demo/posix/cobalt/iddp-label.c
+++ b/demo/posix/cobalt/iddp-label.c
@@ -37,6 +37,8 @@
 #include <string.h>
 #include <pthread.h>
 #include <errno.h>
+
+#include <boilerplate/ancillaries.h>
 #include <rtdm/ipc.h>
 
 pthread_t svtid, cltid;
@@ -180,7 +182,7 @@ static void *client(void *arg)
 		}
 		printf("%s: sent %d bytes, \"%.*s\"\n",
 		       __FUNCTION__, ret, ret, msg[n]);
-		n = (n + 1) % (sizeof(msg) / sizeof(msg[0]));
+		n = (n + 1) % ARRAY_SIZE(msg);
 		/*
 		 * We run in full real-time mode (i.e. primary mode),
 		 * so we have to let the system breathe between two
diff --git a/demo/posix/cobalt/iddp-sendrecv.c b/demo/posix/cobalt/iddp-sendrecv.c
index 31ee10fde..0ce6be2a9 100644
--- a/demo/posix/cobalt/iddp-sendrecv.c
+++ b/demo/posix/cobalt/iddp-sendrecv.c
@@ -32,7 +32,9 @@
 #include <string.h>
 #include <pthread.h>
 #include <errno.h>
+
 #include <rtdm/ipc.h>
+#include <boilerplate/ancillaries.h>
 
 pthread_t svtid, cltid;
 
@@ -136,7 +138,7 @@ static void *client(void *arg)
 		}
 		printf("%s: sent %d bytes, \"%.*s\"\n",
 		       __FUNCTION__, ret, ret, msg[n]);
-		n = (n + 1) % (sizeof(msg) / sizeof(msg[0]));
+		n = (n + 1) % ARRAY_SIZE(msg);
 		/*
 		 * We run in full real-time mode (i.e. primary mode),
 		 * so we have to let the system breathe between two
diff --git a/demo/posix/cobalt/xddp-echo.c b/demo/posix/cobalt/xddp-echo.c
index ba8558266..c76f9e7cc 100644
--- a/demo/posix/cobalt/xddp-echo.c
+++ b/demo/posix/cobalt/xddp-echo.c
@@ -66,6 +66,8 @@
 #include <pthread.h>
 #include <fcntl.h>
 #include <errno.h>
+
+#include <boilerplate/ancillaries.h>
 #include <rtdm/ipc.h>
 
 pthread_t rt, nrt;
@@ -164,7 +166,7 @@ static void *realtime_thread(void *arg)
 
 		printf("   => \"%.*s\" echoed by peer\n", ret, buf);
 
-		n = (n + 1) % (sizeof(msg) / sizeof(msg[0]));
+		n = (n + 1) % ARRAY_SIZE(msg);
 		/*
 		 * We run in full real-time mode (i.e. primary mode),
 		 * so we have to let the system breathe between two
diff --git a/demo/posix/cobalt/xddp-label.c b/demo/posix/cobalt/xddp-label.c
index 9de31fdea..52c898444 100644
--- a/demo/posix/cobalt/xddp-label.c
+++ b/demo/posix/cobalt/xddp-label.c
@@ -72,6 +72,8 @@
 #include <pthread.h>
 #include <fcntl.h>
 #include <errno.h>
+
+#include <boilerplate/ancillaries.h>
 #include <rtdm/ipc.h>
 
 pthread_t rt1, rt2, nrt;
@@ -235,7 +237,7 @@ static void *realtime_thread2(void *arg)
 		printf("%s: sent %d bytes, \"%.*s\"\n",
 		       __FUNCTION__, ret, ret, msg[n]);
 
-		n = (n + 1) % (sizeof(msg) / sizeof(msg[0]));
+		n = (n + 1) % ARRAY_SIZE(msg);
 		/*
 		 * We run in full real-time mode (i.e. primary mode),
 		 * so we have to let the system breathe between two
diff --git a/demo/posix/cobalt/xddp-stream.c b/demo/posix/cobalt/xddp-stream.c
index e53729462..b7934edc4 100644
--- a/demo/posix/cobalt/xddp-stream.c
+++ b/demo/posix/cobalt/xddp-stream.c
@@ -68,6 +68,8 @@
 #include <pthread.h>
 #include <fcntl.h>
 #include <errno.h>
+
+#include <boilerplate/ancillaries.h>
 #include <rtdm/ipc.h>
 
 pthread_t rt, nrt;
@@ -170,7 +172,7 @@ static void *realtime_thread(void *arg)
 
 		printf("   => \"%.*s\" echoed by peer\n", ret, buf);
 
-		n = (n + 1) % (sizeof(msg) / sizeof(msg[0]));
+		n = (n + 1) % ARRAY_SIZE(msg);
 		/*
 		 * We run in full real-time mode (i.e. primary mode),
 		 * so we have to let the system breathe between two
diff --git a/demo/posix/cyclictest/cyclictest.c b/demo/posix/cyclictest/cyclictest.c
index b92596c25..5bc6bd6fc 100644
--- a/demo/posix/cyclictest/cyclictest.c
+++ b/demo/posix/cyclictest/cyclictest.c
@@ -36,15 +36,15 @@
 #include <sys/resource.h>
 #include <sys/utsname.h>
 #include <sys/mman.h>
-#include "rt_numa.h"
 
+#include <boilerplate/ancillaries.h>
+
+#include "rt_numa.h"
 #include "rt-utils.h"
 
 #define DEFAULT_INTERVAL 1000
 #define DEFAULT_DISTANCE 500
 
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
 /* Ugly, but .... */
 #define gettid() syscall(__NR_gettid)
 #define sigev_notify_thread_id _sigev_un._tid

-- 
2.39.2


  parent reply	other threads:[~2023-12-05 12:51 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 ` Florian Bezdeka [this message]
2023-12-05 12:41 ` [PATCH 03/13] lib: " Florian Bezdeka
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-2-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.