]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use gdb_bfd_openr in corelow.c
authorTom Tromey <tromey@adacore.com>
Mon, 2 Mar 2026 16:26:20 +0000 (09:26 -0700)
committerTom Tromey <tromey@adacore.com>
Tue, 3 Mar 2026 17:26:07 +0000 (10:26 -0700)
corelow.c has a couple of calls to bfd_openr, each followed by a call
to new_reference.  It's cleaner to use the provided gdb_bfd_openr
wrapper.

Reviewed-By: Keith Seitz <keiths@redhat.com>
gdb/corelow.c

index a28a707c293a1f3e8cf37815f41c7d7dba071cb8..84f44bc680e2ed84b9f3c18610d3317219066ea5 100644 (file)
@@ -451,10 +451,7 @@ core_target::build_file_mappings ()
 
       gdb_bfd_ref_ptr abfd;
       if (expanded_fname != nullptr && !build_id_mismatch)
-       {
-         struct bfd *b = bfd_openr (expanded_fname.get (), "binary");
-         abfd = gdb_bfd_ref_ptr::new_reference (b);
-       }
+       abfd = gdb_bfd_openr (expanded_fname.get (), "binary");
 
       if ((expanded_fname == nullptr
           || abfd == nullptr
@@ -474,9 +471,8 @@ core_target::build_file_mappings ()
                 type.  */
              expanded_fname
                = make_unique_xstrdup (bfd_get_filename (abfd.get ()));
-             struct bfd *b = bfd_openr (expanded_fname.get (), "binary");
-             gdb_assert (b != nullptr);
-             abfd = gdb_bfd_ref_ptr::new_reference (b);
+             abfd = gdb_bfd_openr (expanded_fname.get (), "binary");
+             gdb_assert (abfd != nullptr);
            }
        }