linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Zhihao Cheng <chengzhihao1@huawei.com>
Cc: peterz@infradead.org, mingo@redhat.com, jolsa@redhat.com,
	ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	nathan@kernel.org, ndesaulniers@google.com,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	clang-built-linux@googlegroups.com, yukuai3@huawei.com
Subject: Re: [PATCH] perf llvm: Fix error return code in llvm__compile_bpf()
Date: Thu, 1 Jul 2021 14:20:13 -0300	[thread overview]
Message-ID: <YN35TYxboEdM5iHc@kernel.org> (raw)
In-Reply-To: <20210609115945.2193194-1-chengzhihao1@huawei.com>

Em Wed, Jun 09, 2021 at 07:59:45PM +0800, Zhihao Cheng escreveu:
> Fix to return a negative error code from the error handling
> case instead of 0, as done elsewhere in this function.

I checked and llvm__compile_bpf() returns -errno, so I'll change this to
instead set err to -ENOMEM just before the if (asprintf)(), ok?

- Arnaldo
 
> Fixes: cb76371441d098 ("perf llvm: Allow passing options to llc ...")
> Fixes: 5eab5a7ee032ac ("perf llvm: Display eBPF compiling command ...")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
> ---
>  tools/perf/util/llvm-utils.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c
> index 3ceaf7ef3301..2de02639fb67 100644
> --- a/tools/perf/util/llvm-utils.c
> +++ b/tools/perf/util/llvm-utils.c
> @@ -504,8 +504,9 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
>  			goto errout;
>  		}
>  
> -		if (asprintf(&pipe_template, "%s -emit-llvm | %s -march=bpf %s -filetype=obj -o -",
> -			      template, llc_path, opts) < 0) {
> +		err = asprintf(&pipe_template, "%s -emit-llvm | %s -march=bpf %s -filetype=obj -o -",
> +			       template, llc_path, opts);
> +		if (err < 0) {
>  			pr_err("ERROR:\tnot enough memory to setup command line\n");
>  			goto errout;
>  		}
> @@ -524,7 +525,8 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
>  
>  	pr_debug("llvm compiling command template: %s\n", template);
>  
> -	if (asprintf(&command_echo, "echo -n \"%s\"", template) < 0)
> +	err = asprintf(&command_echo, "echo -n \"%s\"", template);
> +	if (err < 0)
>  		goto errout;
>  
>  	err = read_from_pipe(command_echo, (void **) &command_out, NULL);
> -- 
> 2.31.1
> 

-- 

- Arnaldo

  reply	other threads:[~2021-07-01 17:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09 11:59 [PATCH] perf llvm: Fix error return code in llvm__compile_bpf() Zhihao Cheng
2021-07-01 17:20 ` Arnaldo Carvalho de Melo [this message]
2021-07-02  3:01   ` Zhihao Cheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YN35TYxboEdM5iHc@kernel.org \
    --to=acme@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chengzhihao1@huawei.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=daniel@iogearbox.net \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).