1 From 275ef3878f698941353780440fec6926107a320b Mon Sep 17 00:00:00 2001
2 From: Jiri Olsa <jolsa@redhat.com>
3 Date: Wed, 5 Sep 2012 19:51:33 +0200
4 Subject: perf tools: Fix cache event name generation
6 From: Jiri Olsa <jolsa@redhat.com>
8 commit 275ef3878f698941353780440fec6926107a320b upstream.
10 If the event name is specified with all 3 components, the last one
11 overwrites the previous one during the name composing within the
12 parse_events_add_cache function.
14 Fixing this by properly adjusting the string index.
16 Reported-by: Joel Uckelman <joel@lightboxtechnologies.com>
17 Signed-off-by: Jiri Olsa <jolsa@redhat.com>
18 Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
19 Cc: Frederic Weisbecker <fweisbec@gmail.com>
20 Cc: Ingo Molnar <mingo@elte.hu>
21 Cc: Joel Uckelman <joel@lightboxtechnologies.com>
22 Cc: Paul Mackerras <paulus@samba.org>
23 Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
24 LPU-Reference: 20120905175133.GA18352@krava.brq.redhat.com
25 [ committer note: Remove the newline fix, done already in 42e1fb7 ]
26 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
27 Cc: Vinson Lee <vlee@twopensource.com>
28 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31 tools/perf/util/parse-events.c | 2 +-
32 1 file changed, 1 insertion(+), 1 deletion(-)
34 --- a/tools/perf/util/parse-events.c
35 +++ b/tools/perf/util/parse-events.c
36 @@ -413,7 +413,7 @@ int parse_events_add_cache(struct list_h
37 for (i = 0; (i < 2) && (op_result[i]); i++) {
38 char *str = op_result[i];
40 - snprintf(name + n, MAX_NAME_LEN - n, "-%s", str);
41 + n += snprintf(name + n, MAX_NAME_LEN - n, "-%s", str);
44 cache_op = parse_aliases(str, hw_cache_op,