lkml.org 
[lkml]   [2017]   [Oct]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 02/18] tracing/filter: use ARRAY_SIZE
Date
It is useless to re-invent the ARRAY_SIZE macro so let's use it instead
of DATA_CNT.

Found with Coccinelle with the following semantic patch:
@r depends on (org || report)@
type T;
T[] E;
position p;
@@
(
(sizeof(E)@p /sizeof(*E))
|
(sizeof(E)@p /sizeof(E[...]))
|
(sizeof(E)@p /sizeof(T))
)

Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>
---
kernel/trace/trace_events_filter.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 61e7f0678d33..02d0f378dc5c 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -23,6 +23,7 @@
#include <linux/mutex.h>
#include <linux/perf_event.h>
#include <linux/slab.h>
+#include <linux/kernel.h>

#include "trace.h"
#include "trace_output.h"
@@ -2376,8 +2377,6 @@ static struct test_filter_data_t {
#undef YES
#undef NO

-#define DATA_CNT (sizeof(test_filter_data)/sizeof(struct test_filter_data_t))
-
static int test_pred_visited;

static int test_pred_visited_fn(struct filter_pred *pred, void *event)
@@ -2417,7 +2416,7 @@ static __init int ftrace_test_event_filter(void)

printk(KERN_INFO "Testing ftrace filter: ");

- for (i = 0; i < DATA_CNT; i++) {
+ for (i = 0; i < ARRAY_SIZE(test_filter_data); i++) {
struct event_filter *filter = NULL;
struct test_filter_data_t *d = &test_filter_data[i];
int err;
@@ -2463,7 +2462,7 @@ static __init int ftrace_test_event_filter(void)
}
}

- if (i == DATA_CNT)
+ if (i == ARRAY_SIZE(test_filter_data))
printk(KERN_CONT "OK\n");

return 0;
--
2.14.1
\
 
 \ /
  Last update: 2017-10-01 21:35    [W:0.214 / U:0.400 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site