From af9da88f14cbe6882b13492b59b3363682427b4d Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Tue, 25 Sep 2012 11:20:28 +0900 Subject: perf test: Fix build failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The commit 6a6cd11d4e57 ("perf test: Add test for the sched tracepoint format fields") added following build error: CC builtin-test.o builtin-test.c: In function ‘perf_evsel__test_field’: builtin-test.c:1216:6: error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable] builtin-test.c: In function ‘perf_evsel__tp_sched_test’: builtin-test.c:1242:6: error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable] cc1: all warnings being treated as errors make: *** [builtin-test.o] Error 1 Signed-off-by: Namhyung Kim Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1348539628-3821-1-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c index 32caf13..78b47a75 100644 --- a/tools/perf/builtin-test.c +++ b/tools/perf/builtin-test.c @@ -1233,7 +1233,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name, ret = -1; } - return 0; + return ret; } static int perf_evsel__tp_sched_test(void) @@ -1286,7 +1286,7 @@ static int perf_evsel__tp_sched_test(void) if (perf_evsel__test_field(evsel, "target_cpu", 4, true)) ret = -1; - return 0; + return ret; } static struct test { -- cgit v0.10.2 From f1b2256d66fe8d613b9afcc1c16079362f9fc05c Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Tue, 25 Sep 2012 21:25:19 +0900 Subject: tools lib traceevent: Fix error path on pevent_parse_event If __pevent_parse_format() succeeded but add_event() failed, 'ret' didn't have a proper error code. Set it to PEVENT_ERRNO__MEM_ALLOC_FAILED. In addition, at that point 'event' also has fields and format information and they all need to be freed. Call pevent_free_format() to handle it. Signed-off-by: Namhyung Kim Cc: Ingo Molnar Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1348575919-4954-1-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 17c9221..47264b4 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -5044,8 +5044,10 @@ enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf, /* Add pevent to event so that it can be referenced */ event->pevent = pevent; - if (add_event(pevent, event)) + if (add_event(pevent, event)) { + ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; goto event_add_failed; + } #define PRINT_ARGS 0 if (PRINT_ARGS && event->print_fmt.args) @@ -5054,9 +5056,7 @@ enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf, return 0; event_add_failed: - free(event->system); - free(event->name); - free(event); + pevent_free_format(event); return ret; } -- cgit v0.10.2