]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use gdb_bfd_sections in more places
authorTom Tromey <tom@tromey.com>
Fri, 5 Dec 2025 21:09:42 +0000 (14:09 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 22 Dec 2025 20:53:02 +0000 (13:53 -0700)
I found a few spots still iterating over sections using "->next", and
thought it would be a little cleaner to use gdb_bfd_sections instead.
In one spot the loop indentation turned out to be wrong as well.

gdb/compile/compile-object-load.c
gdb/dwarf2/read.c

index d9b0539cf7fe4570872f09544b0a0224181ee6a2..45398b1bbda1651c8f72e137e84406706015e7c0 100644 (file)
@@ -628,7 +628,7 @@ compile_object_load (const compile_file_names &file_names,
     error (_("\"%s\": not in object format."), filename.get ());
 
   struct setup_sections_data setup_sections_data (abfd.get ());
-  for (asection *sect = abfd->sections; sect != nullptr; sect = sect->next)
+  for (asection *sect : gdb_bfd_sections (abfd))
     setup_sections_data.setup_one_section (sect);
   setup_sections_data.setup_one_section (nullptr);
 
@@ -720,15 +720,14 @@ compile_object_load (const compile_file_names &file_names,
          asection *toc_fallback = bfd_get_section_by_name(abfd.get(), ".toc");
          if (toc_fallback == NULL)
            {
-             for (asection *tsect = abfd->sections; tsect != nullptr;
-                  tsect = tsect->next)
-                {
-                   if (bfd_section_flags (tsect) & SEC_ALLOC)
-                      {
-                         toc_fallback = tsect;
-                         break;
-                      }
-                }
+             for (asection *tsect : gdb_bfd_sections (abfd))
+               {
+                 if (bfd_section_flags (tsect) & SEC_ALLOC)
+                   {
+                     toc_fallback = tsect;
+                     break;
+                   }
+               }
            }
 
          if (toc_fallback == NULL)
index 12f3e5f0e3dde2f519060f65a97e7895c56f4846..4e2644ba9592330c8264e879a5c95c8a09f61b5a 100644 (file)
@@ -1132,7 +1132,7 @@ dwarf2_per_bfd::dwarf2_per_bfd (bfd *obfd, const dwarf2_debug_sections *names,
   if (names == NULL)
     names = &dwarf2_elf_names;
 
-  for (asection *sec = obfd->sections; sec != NULL; sec = sec->next)
+  for (asection *sec : gdb_bfd_sections (obfd))
     this->locate_sections (sec, *names);
 }