diff mbox series

[rt-tests,3/4] rt-utils: Move ARRAY_SIZE to common header

Message ID 20200901154657.30198-4-dwagner@suse.de
State New
Headers show
Series Fix signaltest output when quiet | expand

Commit Message

Daniel Wagner Sept. 1, 2020, 3:46 p.m. UTC
Move the ARRAY_SIZE macro to a common header to avoid code
duplication.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/cyclictest/cyclictest.c | 2 --
 src/include/rt-utils.h      | 2 ++
 src/signaltest/signaltest.c | 2 --
 3 files changed, 2 insertions(+), 4 deletions(-)

Comments

John Kacur Sept. 3, 2020, 4:38 p.m. UTC | #1
On Tue, 1 Sep 2020, Daniel Wagner wrote:

> Move the ARRAY_SIZE macro to a common header to avoid code
> duplication.
> 
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/cyclictest/cyclictest.c | 2 --
>  src/include/rt-utils.h      | 2 ++
>  src/signaltest/signaltest.c | 2 --
>  3 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
> index ae1d64a46b21..b41d42f13f24 100644
> --- a/src/cyclictest/cyclictest.c
> +++ b/src/cyclictest/cyclictest.c
> @@ -49,8 +49,6 @@
>  #define SCHED_NORMAL SCHED_OTHER
>  #endif
>  
> -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
> -
>  #define sigev_notify_thread_id _sigev_un._tid
>  
>  #ifdef __UCLIBC__
> diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
> index f7b98d9605a0..4ed1cbc53ece 100644
> --- a/src/include/rt-utils.h
> +++ b/src/include/rt-utils.h
> @@ -8,6 +8,8 @@
>  #define STR(x) _STR(x)
>  #define MAX_PATH 256
>  
> +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
> +
>  int check_privs(void);
>  char *get_debugfileprefix(void);
>  int mount_debugfs(char *);
> diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
> index 49d42ff20b6f..0bf075456ab6 100644
> --- a/src/signaltest/signaltest.c
> +++ b/src/signaltest/signaltest.c
> @@ -32,8 +32,6 @@
>  #include "error.h"
>  #include "rt-utils.h"
>  
> -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
> -
>  /* Must be power of 2 ! */
>  #define VALBUF_SIZE		16384
>  
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>
diff mbox series

Patch

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index ae1d64a46b21..b41d42f13f24 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -49,8 +49,6 @@ 
 #define SCHED_NORMAL SCHED_OTHER
 #endif
 
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
 #define sigev_notify_thread_id _sigev_un._tid
 
 #ifdef __UCLIBC__
diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
index f7b98d9605a0..4ed1cbc53ece 100644
--- a/src/include/rt-utils.h
+++ b/src/include/rt-utils.h
@@ -8,6 +8,8 @@ 
 #define STR(x) _STR(x)
 #define MAX_PATH 256
 
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
 int check_privs(void);
 char *get_debugfileprefix(void);
 int mount_debugfs(char *);
diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
index 49d42ff20b6f..0bf075456ab6 100644
--- a/src/signaltest/signaltest.c
+++ b/src/signaltest/signaltest.c
@@ -32,8 +32,6 @@ 
 #include "error.h"
 #include "rt-utils.h"
 
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
 /* Must be power of 2 ! */
 #define VALBUF_SIZE		16384