From: Serhei Makarov Date: Fri, 6 Mar 2026 20:25:16 +0000 (-0500) Subject: backends/: should use size_t n_regs_mapping for *_sample_sp_pc X-Git-Tag: elfutils-0.195~5 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=8bfc4f186909bdff54a8059fc016052c4c2e271d;p=thirdparty%2Felfutils.git backends/: should use size_t n_regs_mapping for *_sample_sp_pc These should have been size_t all along, matching the public libdwfl_stacktrace dwflst_sample_getframes interface. Fix. * backends/aarch64_initreg_sample.c (aarch64_sample_sp_pc): Fixup argument type for n_regs_mapping. * backends/i386_initreg_sample.c (i386_sample_sp_pc): Fixup argument type for n_regs_mapping. * backends/libebl_PERF_FLAGS.h (generic_sample_sp_pc): Fixup argument type for n_regs_mapping, adjust loop index var accordingly. * backends/x86_64_initreg_sample.c (x86_64_sample_sp_pc): Fixup argument type for n_regs_mapping. * libebl/ebl-hooks.h (sample_sp_pc): Fixup argument type for n_regs_mapping. Signed-off-by: Serhei Makarov --- diff --git a/backends/aarch64_initreg_sample.c b/backends/aarch64_initreg_sample.c index 0e8deeda..9aec3697 100644 --- a/backends/aarch64_initreg_sample.c +++ b/backends/aarch64_initreg_sample.c @@ -36,7 +36,7 @@ bool aarch64_sample_sp_pc (const Dwarf_Word *regs, uint32_t n_regs, - const int *regs_mapping, uint32_t n_regs_mapping, + const int *regs_mapping, size_t n_regs_mapping, Dwarf_Word *sp, Dwarf_Word *pc) { return generic_sample_sp_pc (regs, n_regs, regs_mapping, n_regs_mapping, diff --git a/backends/i386_initreg_sample.c b/backends/i386_initreg_sample.c index ae3ab11e..1e194146 100644 --- a/backends/i386_initreg_sample.c +++ b/backends/i386_initreg_sample.c @@ -47,7 +47,7 @@ bool i386_sample_sp_pc (const Dwarf_Word *regs, uint32_t n_regs, - const int *regs_mapping, uint32_t n_regs_mapping, + const int *regs_mapping, size_t n_regs_mapping, Dwarf_Word *sp, Dwarf_Word *pc) { /* XXX for dwarf_regs indices, compare i386_initreg.c */ diff --git a/backends/libebl_PERF_FLAGS.h b/backends/libebl_PERF_FLAGS.h index 33abb603..aa16f456 100644 --- a/backends/libebl_PERF_FLAGS.h +++ b/backends/libebl_PERF_FLAGS.h @@ -75,7 +75,7 @@ static inline bool generic_sample_sp_pc (const Dwarf_Word *regs, uint32_t n_regs, - const int *regs_mapping, uint32_t n_regs_mapping, + const int *regs_mapping, size_t n_regs_mapping, Dwarf_Word *sp, uint sp_index /* into dwarf_regs */, Dwarf_Word *pc, uint pc_index /* into dwarf_regs */) { @@ -84,8 +84,8 @@ generic_sample_sp_pc (const Dwarf_Word *regs, uint32_t n_regs, /* TODO: Register locations could be cached and rechecked on a fastpath without needing to loop, though the overhead reduction is minimal. */ - int j, need_sp = (sp != NULL), need_pc = (pc != NULL); - for (j = 0; (need_sp || need_pc) && n_regs_mapping > (uint32_t)j; j++) + int need_sp = (sp != NULL), need_pc = (pc != NULL); + for (size_t j = 0; (need_sp || need_pc) && n_regs_mapping > j; j++) { if (n_regs <= (uint32_t)j) break; if (need_sp && regs_mapping[j] == (int)sp_index) diff --git a/backends/x86_64_initreg_sample.c b/backends/x86_64_initreg_sample.c index 83966ff9..48a365f5 100644 --- a/backends/x86_64_initreg_sample.c +++ b/backends/x86_64_initreg_sample.c @@ -47,7 +47,7 @@ bool x86_64_sample_sp_pc (const Dwarf_Word *regs, uint32_t n_regs, - const int *regs_mapping, uint32_t n_regs_mapping, + const int *regs_mapping, size_t n_regs_mapping, Dwarf_Word *sp, Dwarf_Word *pc) { /* XXX for dwarf_regs indices, compare x86_64_initreg.c */ diff --git a/libebl/ebl-hooks.h b/libebl/ebl-hooks.h index 29ce9649..054284d8 100644 --- a/libebl/ebl-hooks.h +++ b/libebl/ebl-hooks.h @@ -172,7 +172,7 @@ bool EBLHOOK(set_initial_registers_sample) (const Dwarf_Word *regs, /* Extract the stack address and instruction pointer from a register sample. */ bool EBLHOOK(sample_sp_pc) (const Dwarf_Word *regs, uint32_t n_regs, const int *regs_mapping, - uint32_t n_regs_mapping, + size_t n_regs_mapping, Dwarf_Word *sp, Dwarf_Word *pc); /* Translate from linux perf_events PERF_REGS_MASK and ABI to a generic