All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: fix missing event name init for default event
@ 2011-06-06 15:10 Stephane Eranian
  2011-06-06 17:32 ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Stephane Eranian @ 2011-06-06 15:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: mingo, peterz, acme


When no event is given to perf record, perf top, a default
event is initialized (cycles). However, perf_evlist__add_default()
was not setting the symbolic name for the event. Perf top
worked simply because it was reconstructing the name from the event
code. But it should not have to do this. This patch initializes the
evsel->name field properly.

Signed-off-by: Stephane Eranian <eranian@google.com>
---

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index b021ea9..1584af6 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -87,6 +87,13 @@ int perf_evlist__add_default(struct perf_evlist *evlist)
 	if (evsel == NULL)
 		return -ENOMEM;
 
+	/* use strdup() because free(evsel) assumes name is allocated */
+	evsel->name = strdup("cycles");
+	if (!evsel->name) {
+		free(evsel);
+		return -ENOMEM;
+	}
+
 	perf_evlist__add(evlist, evsel);
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-06-07 15:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-06 15:10 [PATCH] perf: fix missing event name init for default event Stephane Eranian
2011-06-06 17:32 ` Ingo Molnar
2011-06-07 15:45   ` Stephane Eranian

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.