linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf tools: Remove a pointless check
@ 2025-08-08 22:26 Namhyung Kim
  2025-08-18 22:17 ` Ian Rogers
  0 siblings, 1 reply; 2+ messages in thread
From: Namhyung Kim @ 2025-08-08 22:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
  Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
	linux-perf-users, David Binderman

Static analyser cppcheck says:

  linux-6.16/tools/perf/util/tool_pmu.c:242:15: warning:
      Opposite inner 'if' condition leads to a dead code block. [oppositeInnerCondition]

Source code is

        for (thread = 0; thread < nthreads; thread++) {
            if (thread >= nthreads)
                break;

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/tool_pmu.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/tools/perf/util/tool_pmu.c b/tools/perf/util/tool_pmu.c
index d99e699e646dd651..f075098488baddd9 100644
--- a/tools/perf/util/tool_pmu.c
+++ b/tools/perf/util/tool_pmu.c
@@ -239,9 +239,6 @@ int evsel__tool_pmu_open(struct evsel *evsel,
 	nthreads = perf_thread_map__nr(threads);
 	for (idx = start_cpu_map_idx; idx < end_cpu_map_idx; idx++) {
 		for (thread = 0; thread < nthreads; thread++) {
-			if (thread >= nthreads)
-				break;
-
 			if (!evsel->cgrp && !evsel->core.system_wide)
 				pid = perf_thread_map__pid(threads, thread);
 
-- 
2.51.0.rc0.155.g4a0f42376b-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf tools: Remove a pointless check
  2025-08-08 22:26 [PATCH] perf tools: Remove a pointless check Namhyung Kim
@ 2025-08-18 22:17 ` Ian Rogers
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Rogers @ 2025-08-18 22:17 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Kan Liang, Jiri Olsa, Adrian Hunter,
	Peter Zijlstra, Ingo Molnar, LKML, linux-perf-users,
	David Binderman

On Fri, Aug 8, 2025 at 3:26 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Static analyser cppcheck says:
>
>   linux-6.16/tools/perf/util/tool_pmu.c:242:15: warning:
>       Opposite inner 'if' condition leads to a dead code block. [oppositeInnerCondition]
>
> Source code is
>
>         for (thread = 0; thread < nthreads; thread++) {
>             if (thread >= nthreads)
>                 break;
>
> Reported-by: David Binderman <dcb314@hotmail.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/util/tool_pmu.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/tools/perf/util/tool_pmu.c b/tools/perf/util/tool_pmu.c
> index d99e699e646dd651..f075098488baddd9 100644
> --- a/tools/perf/util/tool_pmu.c
> +++ b/tools/perf/util/tool_pmu.c
> @@ -239,9 +239,6 @@ int evsel__tool_pmu_open(struct evsel *evsel,
>         nthreads = perf_thread_map__nr(threads);
>         for (idx = start_cpu_map_idx; idx < end_cpu_map_idx; idx++) {
>                 for (thread = 0; thread < nthreads; thread++) {
> -                       if (thread >= nthreads)
> -                               break;
> -
>                         if (!evsel->cgrp && !evsel->core.system_wide)
>                                 pid = perf_thread_map__pid(threads, thread);
>
> --
> 2.51.0.rc0.155.g4a0f42376b-goog
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-18 22:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-08 22:26 [PATCH] perf tools: Remove a pointless check Namhyung Kim
2025-08-18 22:17 ` Ian Rogers

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).