[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-ec60a3fe478c0fc6d109eb5840b435ecee4d132b@git.kernel.org>
Date: Sat, 19 Sep 2009 17:01:54 GMT
From: tip-bot for Arjan van de Ven <arjan@...radead.org>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, paulus@...ba.org,
arjan@...radead.org, hpa@...or.com, mingo@...hat.com,
arjan@...ux.intel.com, tglx@...utronix.de, mingo@...e.hu
Subject: [tip:perfcounters/core] perf utils: Use a define for the maximum length of a trace event
Commit-ID: ec60a3fe478c0fc6d109eb5840b435ecee4d132b
Gitweb: http://git.kernel.org/tip/ec60a3fe478c0fc6d109eb5840b435ecee4d132b
Author: Arjan van de Ven <arjan@...radead.org>
AuthorDate: Sat, 19 Sep 2009 13:36:30 +0200
Committer: Ingo Molnar <mingo@...e.hu>
CommitDate: Sat, 19 Sep 2009 18:57:53 +0200
perf utils: Use a define for the maximum length of a trace event
As per Ingo's review: use a #define rather than an open coded constant
for the maximum length of a trace event for storing in the perf.data file.
Signed-off-by: Arjan van de Ven <arjan@...ux.intel.com>
Cc: fweisbec@...il.com
Cc: peterz@...radead.org
Cc: Paul Mackerras <paulus@...ba.org>
LKML-Reference: <20090919133630.10533d3e@...radead.org>
[ add a few comments to nearby functions ]
Signed-off-by: Ingo Molnar <mingo@...e.hu>
---
tools/perf/util/header.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index ef91145..bb4fca3 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -7,9 +7,8 @@
#include "header.h"
/*
- *
+ * Create new perf.data header attribute:
*/
-
struct perf_header_attr *perf_header_attr__new(struct perf_counter_attr *attr)
{
struct perf_header_attr *self = malloc(sizeof(*self));
@@ -43,9 +42,8 @@ void perf_header_attr__add_id(struct perf_header_attr *self, u64 id)
}
/*
- *
+ * Create new perf.data header:
*/
-
struct perf_header *perf_header__new(void)
{
struct perf_header *self = malloc(sizeof(*self));
@@ -86,9 +84,11 @@ void perf_header__add_attr(struct perf_header *self,
self->attr[pos] = attr;
}
+#define MAX_EVENT_NAME 64
+
struct perf_trace_event_type {
u64 event_id;
- char name[64];
+ char name[MAX_EVENT_NAME];
};
static int event_count;
@@ -96,7 +96,7 @@ static struct perf_trace_event_type *events;
void perf_header__push_event(u64 id, const char *name)
{
- if (strlen(name) > 64)
+ if (strlen(name) > MAX_EVENT_NAME)
printf("Event %s will be truncated\n", name);
if (!events) {
@@ -110,7 +110,7 @@ void perf_header__push_event(u64 id, const char *name)
}
memset(&events[event_count], 0, sizeof(struct perf_trace_event_type));
events[event_count].event_id = id;
- strncpy(events[event_count].name, name, 63);
+ strncpy(events[event_count].name, name, MAX_EVENT_NAME - 1);
event_count++;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists