Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/rtla: Fix unassigned nr_cpus

In recently introduced timerlat_free(),
the variable 'nr_cpus' is not assigned.

Assign it with sysconf(_SC_NPROCESSORS_CONF) as done elsewhere.
Remove the culprit: -Wno-maybe-uninitialized. The rest of the
code is clean.

Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
Reviewed-by: Tomas Glozar <tglozar@redhat.com>
Fixes: 2f3172f9dd58 ("tools/rtla: Consolidate code between osnoise/timerlat and hist/top")
Link: https://lore.kernel.org/r/20251002170846.437888-1-costa.shul@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>

authored by

Costa Shulyupin and committed by
Tomas Glozar
b4275b23 671314fc

+3 -2
+1 -1
tools/tracing/rtla/Makefile.rtla
··· 18 18 FOPTS := -flto=auto -ffat-lto-objects -fexceptions -fstack-protector-strong \ 19 19 -fasynchronous-unwind-tables -fstack-clash-protection 20 20 WOPTS := -O -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 \ 21 - -Wp,-D_GLIBCXX_ASSERTIONS -Wno-maybe-uninitialized 21 + -Wp,-D_GLIBCXX_ASSERTIONS 22 22 23 23 ifeq ($(CC),clang) 24 24 FOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(FOPTS))
+2 -1
tools/tracing/rtla/src/timerlat.c
··· 213 213 void timerlat_free(struct osnoise_tool *tool) 214 214 { 215 215 struct timerlat_params *params = to_timerlat_params(tool->params); 216 - int nr_cpus, i; 216 + int nr_cpus = sysconf(_SC_NPROCESSORS_CONF); 217 + int i; 217 218 218 219 timerlat_aa_destroy(); 219 220 if (dma_latency_fd >= 0)