[binutils-gdb] gdb: use enumerate in gdbtypes.c

Simon Marchi via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cc9d69394628641235da1483788c0d938c9b6661

commit cc9d69394628641235da1483788c0d938c9b6661
Author: Simon Marchi <[email protected]>
Date:   Fri Feb 20 20:19:00 2026 -0500

    gdb: use enumerate in gdbtypes.c
    
    Use the new enumerate util to move to a range-based loop, while keeping
    the counter.
    
    Change-Id: If82eaec7afa4e78fa51e973fae4d0ecef728ea95

Diff:
---
 gdb/gdbtypes.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index a5aa1e048f5..07a8c7065ea 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -44,6 +44,7 @@
 #include "rust-lang.h"
 #include "ada-lang.h"
 #include "extract-store-integer.h"
+#include "gdbsupport/enumerate.h"
 
 /* The value of an invalid conversion badness.  */
 #define INVALID_CONVERSION 100
@@ -4832,12 +4833,12 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value)
 static void
 print_args (gdb::array_view<struct field> args, int spaces)
 {
-  for (int i = 0; i < args.size (); i++)
+  for (auto [i, arg] : gdb::ranges::views::enumerate (args))
     {
       gdb_printf
-	("%*s[%d] name '%s'\n", spaces, "", i,
-	 args[i].name () != NULL ? args[i].name () : "<NULL>");
-      recursive_dump_type (args[i].type (), spaces + 2);
+	("%*s[%zu] name '%s'\n", spaces, "", i,
+	 arg.name () != nullptr ? arg.name () : "<NULL>");
+      recursive_dump_type (arg.type (), spaces + 2);
     }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.