Commit 11db4e29 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Arnaldo Carvalho de Melo

perf pmu: Make pmu_formats_string to check return value of strbuf

Make pmu_formats_string() to check return value of strbuf APIs so that
it can detect errors in it.
Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20160510054744.6158.37810.stgit@devboxSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 642aadaa
......@@ -643,20 +643,20 @@ static int pmu_resolve_param_term(struct parse_events_term *term,
static char *pmu_formats_string(struct list_head *formats)
{
struct perf_pmu_format *format;
char *str;
struct strbuf buf;
char *str = NULL;
struct strbuf buf = STRBUF_INIT;
unsigned i = 0;
if (!formats)
return NULL;
strbuf_init(&buf, 0);
/* sysfs exported terms */
list_for_each_entry(format, formats, list)
strbuf_addf(&buf, i++ ? ",%s" : "%s",
format->name);
if (strbuf_addf(&buf, i++ ? ",%s" : "%s", format->name) < 0)
goto error;
str = strbuf_detach(&buf, NULL);
error:
strbuf_release(&buf);
return str;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment