lkml.org 
[lkml]   [2017]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 09/11] trace-cmd: Consolidate ARRAY_SIZE() in trace-cmd.h
Date
Since ARRAY_SIZE() is a very useful macro, it makes sense to move it in a common
header file, in order to avoid several C files to re-define it.

Signed-off-by: Vladislav Valtchev (VMware) <vladislav.valtchev@gmail.com>
---
plugin_blk.c | 1 -
trace-cmd.c | 2 --
trace-cmd.h | 2 ++
3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/plugin_blk.c b/plugin_blk.c
index e87bebb..a1b5df0 100644
--- a/plugin_blk.c
+++ b/plugin_blk.c
@@ -30,7 +30,6 @@
#define MINORMASK ((1U << MINORBITS) - 1)
#define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

struct blk_data {
unsigned long long sector;
diff --git a/trace-cmd.c b/trace-cmd.c
index 7297756..6c2efa3 100644
--- a/trace-cmd.c
+++ b/trace-cmd.c
@@ -117,8 +117,6 @@ struct command commands[] = {
{"-h", trace_usage},
};

-#define ARRAY_SIZE(_a) (sizeof(_a) / sizeof(_a[0]))
-
int main (int argc, char **argv)
{
int i;
diff --git a/trace-cmd.h b/trace-cmd.h
index 485907f..3fb6aab 100644
--- a/trace-cmd.h
+++ b/trace-cmd.h
@@ -22,6 +22,8 @@

#include "event-parse.h"

+#define ARRAY_SIZE(_a) (sizeof(_a) / sizeof((_a)[0]))
+
#define TRACECMD_ERR_MSK ((unsigned long)(-1) & ~((1UL << 14) - 1))
#define TRACECMD_ISERR(ptr) ((unsigned long)(ptr) > TRACECMD_ERR_MSK)
#define TRACECMD_ERROR(ret) ((void *)((unsigned long)(ret) | TRACECMD_ERR_MSK))
--
2.14.1
\
 
 \ /
  Last update: 2017-11-23 17:37    [W:0.198 / U:0.440 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site