Skip to contentSkip to conversation

perf tools: Remove a pointless check

PATCH In review Namhyung Kim 2 participants 2 messages Aug 8, 2025 – Aug 18, 2025 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf tools: Remove a pointless check

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;
---
 tools/perf/util/tool_pmu.c | 3 ---
 1 file changed, 3 deletions(-)
tools/perf/util/tool_pmu.c +0 -3
index d99e699e646dd651..f075098488baddd9 100644
@@ -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);
 
Signature · 1 line
2.51.0.rc0.155.g4a0f42376b-goog
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Namhyung Kim

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]

Quoted 8 lines

Source code is

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

Thanks,
Ian

Quoted 21 lines
---
 tools/perf/util/tool_pmu.c | 3 ---
 1 file changed, 3 deletions(-)
tools/perf/util/tool_pmu.c +0 -4
index d99e699e646dd651..f075098488baddd9 100644
@@ -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