]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
backends/: should use size_t n_regs_mapping for *_sample_sp_pc
authorSerhei Makarov <serhei@serhei.io>
Fri, 6 Mar 2026 20:25:16 +0000 (15:25 -0500)
committerSerhei Makarov <serhei@serhei.io>
Tue, 14 Apr 2026 20:51:36 +0000 (16:51 -0400)
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 <serhei@serhei.io>
backends/aarch64_initreg_sample.c
backends/i386_initreg_sample.c
backends/libebl_PERF_FLAGS.h
backends/x86_64_initreg_sample.c
libebl/ebl-hooks.h

index 0e8deedaaeaa9526b5f38ad5edffd33d4ac154f4..9aec36972bd5e9f19df6be2e6b3323b68beee433 100644 (file)
@@ -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,
index ae3ab11e9183d6b4d8708eee453c3b4a41f993b0..1e194146e4ec0df3950b6a029decfa307cc61b72 100644 (file)
@@ -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 */
index 33abb603be2690e03f13de1a245d2a0d680a2c38..aa16f4560903485e7c1d84e0bb81574edcdd967f 100644 (file)
@@ -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)
index 83966ff9e38b79b7f769a9b7cef13c63d1e64e88..48a365f50a0910d4a97657e311b29fc695fc9e6e 100644 (file)
@@ -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 */
index 29ce96494ee8f7783fff183b71c724a9d2f51a1a..054284d8a160d3d0364aa43fdce6820914cbdc3a 100644 (file)
@@ -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