Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1174449 > unrolled thread

Re: [PATCH 4/5] perf mem: Fill in the missing freeing a session after an error occur

Started byJiri Olsa <jolsa@redhat.com>
First post2015-06-30 13:20 +0200
Last post2015-06-30 13:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 4/5] perf mem: Fill in the missing freeing a session  after an error occur Jiri Olsa <jolsa@redhat.com> - 2015-06-30 13:20 +0200

#1174449 — Re: [PATCH 4/5] perf mem: Fill in the missing freeing a session after an error occur

FromJiri Olsa <jolsa@redhat.com>
Date2015-06-30 13:20 +0200
SubjectRe: [PATCH 4/5] perf mem: Fill in the missing freeing a session after an error occur
Message-ID<pH1K1-ax-1@gated-at.bofh.it>
On Tue, Jun 30, 2015 at 05:15:23PM +0900, Taeung Song wrote:
> 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 | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
> index da2ec06..8b6d473 100644
> --- a/tools/perf/builtin-mem.c
> +++ b/tools/perf/builtin-mem.c
> @@ -135,24 +135,27 @@ 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 = err;
>  			goto out_delete;
> +		}
>  	}
>  
> -	if (symbol__init(&session->header.env) < 0)
> -		return -1;
> +	ret = symbol__init(&session->header.env);
> +	if (ret < 0)
> +		goto out_delete;
>  
>  	printf("# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n");
>  
>  	err = perf_session__process_events(session);
>  	if (err)
> -		return err;
> -
> -	return 0;
> +		ret = err;
> +	else
> +		ret = 0;

hum.. how about just:
	ret = perf_session__process_events(session);

and fall through..

also I guess we could get rid of one of those 'ret' and 'err' and use just one?

jirka

>  
>  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
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web