* [PATCH] perf print-events: Remove redundant comparison with zero
@ 2022-11-05 13:59 Kang Minchul
2022-11-07 20:59 ` Namhyung Kim
0 siblings, 1 reply; 2+ messages in thread
From: Kang Minchul @ 2022-11-05 13:59 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo
Cc: Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
linux-perf-users, linux-kernel, Kang Minchul
Since variable npmus is unsigned int, comparing with 0 is unnecessary.
Signed-off-by: Kang Minchul <tegongkang@gmail.com>
---
tools/perf/util/print-events.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/print-events.c b/tools/perf/util/print-events.c
index c4d5d87fae2f..6df947df1c0f 100644
--- a/tools/perf/util/print-events.c
+++ b/tools/perf/util/print-events.c
@@ -311,10 +311,8 @@ int print_hwcache_events(const char *event_glob, bool name_only)
if ((hybrid_supported == 0) ||
(hybrid_supported == npmus)) {
evt_list[evt_i] = strdup(name);
- if (npmus > 0) {
- for (j = 0; j < npmus; j++)
- zfree(&evt_pmus[j]);
- }
+ for (j = 0; j < npmus; j++)
+ zfree(&evt_pmus[j]);
} else {
for (j = 0; j < hybrid_supported; j++) {
evt_list[evt_i++] = evt_pmus[j];
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] perf print-events: Remove redundant comparison with zero
2022-11-05 13:59 [PATCH] perf print-events: Remove redundant comparison with zero Kang Minchul
@ 2022-11-07 20:59 ` Namhyung Kim
0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2022-11-07 20:59 UTC (permalink / raw)
To: Kang Minchul
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, linux-perf-users,
linux-kernel
Hi Minchul,
On Sat, Nov 5, 2022 at 6:59 AM Kang Minchul <tegongkang@gmail.com> wrote:
>
> Since variable npmus is unsigned int, comparing with 0 is unnecessary.
>
> Signed-off-by: Kang Minchul <tegongkang@gmail.com>
> ---
> tools/perf/util/print-events.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/util/print-events.c b/tools/perf/util/print-events.c
> index c4d5d87fae2f..6df947df1c0f 100644
> --- a/tools/perf/util/print-events.c
> +++ b/tools/perf/util/print-events.c
> @@ -311,10 +311,8 @@ int print_hwcache_events(const char *event_glob, bool name_only)
> if ((hybrid_supported == 0) ||
> (hybrid_supported == npmus)) {
> evt_list[evt_i] = strdup(name);
> - if (npmus > 0) {
> - for (j = 0; j < npmus; j++)
> - zfree(&evt_pmus[j]);
> - }
> + for (j = 0; j < npmus; j++)
> + zfree(&evt_pmus[j]);
You can still have 0 npmus, but then the for loop will not be executed. So,
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
> } else {
> for (j = 0; j < hybrid_supported; j++) {
> evt_list[evt_i++] = evt_pmus[j];
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-07 20:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-05 13:59 [PATCH] perf print-events: Remove redundant comparison with zero Kang Minchul
2022-11-07 20:59 ` Namhyung Kim
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).