summaryrefslogtreecommitdiff
path: root/tools/lib/perf/include/internal
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2026-03-31 11:29:48 -0700
committerNamhyung Kim <namhyung@kernel.org>2026-04-01 14:50:53 -0700
commit83c338369a88eeab8cc64446c7ba9bb8ffb37e4a (patch)
treebdd47dab3a86b631d4d4d882eb69a8c9b7ce3fb1 /tools/lib/perf/include/internal
parent7f8969aa739da4d2096f2e6f87e030de6efad9dc (diff)
libperf cpumap: Make index and nr types unsigned
The index into the cpumap array and the number of entries within the array can never be negative, so let's make them unsigned. This is prompted by reports that gcc 13 with -O6 is giving a alloc-size-larger-than errors. The change makes the cpumap changes and then updates the declaration of index variables throughout perf and libperf to be unsigned. The two things are hard to separate as compiler warnings about mixing signed and unsigned types breaks the build. Reported-by: Chingbin Li <liqb365@163.com> Closes: https://lore.kernel.org/lkml/20260212025127.841090-1-liqb365@163.com/ Tested-by: Chingbin Li <liqb365@163.com> Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/lib/perf/include/internal')
-rw-r--r--tools/lib/perf/include/internal/cpumap.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/lib/perf/include/internal/cpumap.h b/tools/lib/perf/include/internal/cpumap.h
index e2be2d17c32b..c19678188b17 100644
--- a/tools/lib/perf/include/internal/cpumap.h
+++ b/tools/lib/perf/include/internal/cpumap.h
@@ -16,16 +16,16 @@
DECLARE_RC_STRUCT(perf_cpu_map) {
refcount_t refcnt;
/** Length of the map array. */
- int nr;
+ unsigned int nr;
/** The CPU values. */
struct perf_cpu map[];
};
-struct perf_cpu_map *perf_cpu_map__alloc(int nr_cpus);
+struct perf_cpu_map *perf_cpu_map__alloc(unsigned int nr_cpus);
int perf_cpu_map__idx(const struct perf_cpu_map *cpus, struct perf_cpu cpu);
bool perf_cpu_map__is_subset(const struct perf_cpu_map *a, const struct perf_cpu_map *b);
-void perf_cpu_map__set_nr(struct perf_cpu_map *map, int nr_cpus);
+void perf_cpu_map__set_nr(struct perf_cpu_map *map, unsigned int nr_cpus);
static inline refcount_t *perf_cpu_map__refcnt(struct perf_cpu_map *map)
{