lkml.org 
[lkml]   [2015]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 4/5] perf mem: Fill in the missing freeing a session after an error occur
Em Wed, Jul 01, 2015 at 12:18:45AM +0900, Taeung Song escreveu:
> When an error occur a error value is just returned
> without freeing the session. So allocating and freeing
> session have to be matched as a pair even if an error occur.
>
> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
> ---
> tools/perf/builtin-mem.c | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
> index da2ec06..a914ef7 100644
> --- a/tools/perf/builtin-mem.c
> +++ b/tools/perf/builtin-mem.c
> @@ -124,7 +124,6 @@ static int report_raw_events(struct perf_mem *mem)
> .mode = PERF_DATA_MODE_READ,
> .force = mem->force,
> };
> - int err = -EINVAL;
> int ret;
> struct perf_session *session = perf_session__new(&file, false,
> &mem->tool);
> @@ -135,24 +134,23 @@ static int report_raw_events(struct perf_mem *mem)
> if (mem->cpu_list) {
> ret = perf_session__cpu_bitmap(session, mem->cpu_list,
> mem->cpu_bitmap);
> - if (ret)
> + if (ret) {
> + ret = -EINVAL;

Why not propagate perf_session__cpu_bitmap() return, this function
wasn't being consistent in returning errors, neither was you, as, see
below...

> goto out_delete;
> + }
> }
>
> - if (symbol__init(&session->header.env) < 0)
> - return -1;
> + ret = symbol__init(&session->header.env);
> + if (ret < 0)
> + goto out_delete;

Here you decided to propagate symbol__init() error return. :-)

I applied all the others, including the 3/5 v2 one.

Thanks,

- Arnaldo

>
> printf("# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n");
>
> - err = perf_session__process_events(session);
> - if (err)
> - return err;
> -
> - return 0;
> + ret = perf_session__process_events(session);
>
> out_delete:
> perf_session__delete(session);
> - return err;
> + return ret;
> }
>
> static int report_events(int argc, const char **argv, struct perf_mem *mem)
> --
> 1.9.1


\
 
 \ /
  Last update: 2015-06-30 22:21    [W:0.104 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site