From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Chen Zhongjin <chenzhongjin@huawei.com>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
namhyung@kernel.org, irogers@google.com, john.garry@huawei.com,
adrian.hunter@intel.com, ak@linux.intel.com,
florian.fischer@muhq.space
Subject: Re: [PATCH -next 3/5] perf: Remove duplicate errbuf
Date: Mon, 26 Sep 2022 20:54:24 +0100 [thread overview]
Message-ID: <YzIDcPVXLabTeZ11@kernel.org> (raw)
In-Reply-To: <20220926031440.28275-4-chenzhongjin@huawei.com>
Em Mon, Sep 26, 2022 at 11:14:38AM +0800, Chen Zhongjin escreveu:
> char errbuf[BUFSIZ] is defined twice in trace__run.
>
> However out_error_open is not cross to other out_error path, they can
> share one errbuf together.
>
> Define the errbuf[BUFSIZ] at the beginning of function, and remove the
> redefinations of them for code cleaning.
Have you looked at the end result in the generated code? Just out of
curiosity.
- Arnaldo
> Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
> ---
> tools/perf/builtin-trace.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index 7ecd76428440..5660c0ee3507 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -3937,6 +3937,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
> unsigned long before;
> const bool forks = argc > 0;
> bool draining = false;
> + char errbuf[BUFSIZ];
>
> trace->live = true;
>
> @@ -4027,8 +4028,6 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
>
> err = bpf__apply_obj_config();
> if (err) {
> - char errbuf[BUFSIZ];
> -
> bpf__strerror_apply_obj_config(err, errbuf, sizeof(errbuf));
> pr_err("ERROR: Apply config to BPF failed: %s\n",
> errbuf);
> @@ -4185,8 +4184,6 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
> trace->evlist = NULL;
> trace->live = false;
> return err;
> -{
> - char errbuf[BUFSIZ];
>
> out_error_sched_stat_runtime:
> tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "sched", "sched_stat_runtime");
> @@ -4213,7 +4210,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
> evsel->filter, evsel__name(evsel), errno,
> str_error_r(errno, errbuf, sizeof(errbuf)));
> goto out_delete_evlist;
> -}
> +
> out_error_mem:
> fprintf(trace->output, "Not enough memory to run!\n");
> goto out_delete_evlist;
> --
> 2.17.1
--
- Arnaldo
next prev parent reply other threads:[~2022-09-26 19:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-26 3:14 [PATCH -next 0/5] perf: Minor fixes and cleanup Chen Zhongjin
2022-09-26 3:14 ` [PATCH -next 1/5] perf: Fix show_arg_names not working for tp arg names Chen Zhongjin
2022-09-26 19:50 ` Arnaldo Carvalho de Melo
2022-09-26 3:14 ` [PATCH -next 2/5] perf: Fix incorrectly parsed flags in filter Chen Zhongjin
2022-09-26 19:51 ` Arnaldo Carvalho de Melo
2022-09-26 3:14 ` [PATCH -next 3/5] perf: Remove duplicate errbuf Chen Zhongjin
2022-09-26 19:54 ` Arnaldo Carvalho de Melo [this message]
2022-09-27 1:20 ` Chen Zhongjin
2022-09-26 3:14 ` [PATCH -next 4/5] perf: Remove unused macros __PERF_EVENT_FIELD Chen Zhongjin
2022-09-26 19:48 ` Arnaldo Carvalho de Melo
2022-09-26 3:14 ` [PATCH -next 5/5] perf: Remove unused macro K Chen Zhongjin
2022-09-26 19:47 ` Arnaldo Carvalho de Melo
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=YzIDcPVXLabTeZ11@kernel.org \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=chenzhongjin@huawei.com \
--cc=florian.fischer@muhq.space \
--cc=irogers@google.com \
--cc=john.garry@huawei.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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).