diff options
author | Irina Tirdea <irina.tirdea@intel.com> | 2012-09-20 16:37:50 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-09-24 10:49:31 -0400 |
commit | bcbd004020bf0d725722be75da35fd326ff63ef4 (patch) | |
tree | 82510369c7a6583b40a7d81d2ff4bbab6f835804 /tools/perf/util/trace-event-parse.c | |
parent | 37e9d750e672d6fa8c25463bd76240410bbbc786 (diff) |
perf tools: remove sscanf extension %as
perf uses sscanf extension %as to read and allocate a string in the same
step. This is a non-standard extension only present in new versions of
glibc.
Replacing the use of sscanf and %as with strtok_r calls in order to
parse a given string into its components. This is needed in Android
since bionic does not support
%as extension for sscanf.
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1348173470-4936-1-git-send-email-irina.tirdea@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/trace-event-parse.c')
-rw-r--r-- | tools/perf/util/trace-event-parse.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index aa4c860a21d1..3aabcd687cd5 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c | |||
@@ -229,24 +229,22 @@ void parse_proc_kallsyms(struct pevent *pevent, | |||
229 | char *next = NULL; | 229 | char *next = NULL; |
230 | char *addr_str; | 230 | char *addr_str; |
231 | char *mod; | 231 | char *mod; |
232 | char ch; | 232 | char *fmt; |
233 | 233 | ||
234 | line = strtok_r(file, "\n", &next); | 234 | line = strtok_r(file, "\n", &next); |
235 | while (line) { | 235 | while (line) { |
236 | mod = NULL; | 236 | mod = NULL; |
237 | sscanf(line, "%as %c %as\t[%as", | 237 | addr_str = strtok_r(line, " ", &fmt); |
238 | (float *)(void *)&addr_str, /* workaround gcc warning */ | ||
239 | &ch, (float *)(void *)&func, (float *)(void *)&mod); | ||
240 | addr = strtoull(addr_str, NULL, 16); | 238 | addr = strtoull(addr_str, NULL, 16); |
241 | free(addr_str); | 239 | /* skip character */ |
242 | 240 | strtok_r(NULL, " ", &fmt); | |
243 | /* truncate the extra ']' */ | 241 | func = strtok_r(NULL, "\t", &fmt); |
242 | mod = strtok_r(NULL, "]", &fmt); | ||
243 | /* truncate the extra '[' */ | ||
244 | if (mod) | 244 | if (mod) |
245 | mod[strlen(mod) - 1] = 0; | 245 | mod = mod + 1; |
246 | 246 | ||
247 | pevent_register_function(pevent, func, addr, mod); | 247 | pevent_register_function(pevent, func, addr, mod); |
248 | free(func); | ||
249 | free(mod); | ||
250 | 248 | ||
251 | line = strtok_r(NULL, "\n", &next); | 249 | line = strtok_r(NULL, "\n", &next); |
252 | } | 250 | } |