Messages in this thread Patch in this message | | | Date | Sat, 19 Sep 2009 13:36:30 +0200 | From | Arjan van de Ven <> | Subject | [PATCH] perf: Use a define for the maximum length of a trace event |
| |
From e5f5037ae4423c188aa68ee6ba239708bb720722 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven <arjan@linux.intel.com> Date: Sat, 19 Sep 2009 13:21:20 +0200 Subject: [PATCH] perf: 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@linux.intel.com> --- tools/perf/util/header.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index ef91145..ed6b553 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -86,9 +86,10 @@ 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 +97,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 +111,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++; } -- 1.6.0.6
-- Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org
| |