]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix uninitialized warning in gdb_bfd_open
authorTom Tromey <tromey@adacore.com>
Tue, 8 Sep 2020 16:35:22 +0000 (10:35 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 8 Sep 2020 16:35:22 +0000 (10:35 -0600)
The previous patch introduced an uninitialized warning in
gdb_bfd_open.  The problem was that "abfd" was being used without
being initialized.

This patch fixes the problem by calling bfd_fopen in the branch where
"fstat" has failed.

gdb/ChangeLog
2020-09-08  Tom Tromey  <tromey@adacore.com>

* gdb_bfd.c (gdb_bfd_open): Call bfd_fopen when fstat fails.

gdb/ChangeLog
gdb/gdb_bfd.c

index 01daa99869ba26cfb2a9d24e62d6739f03f703b4..c8d46901c9fdc393bf2c1ae88981cbbedaf7edf5 100644 (file)
@@ -1,3 +1,7 @@
+2020-09-08  Tom Tromey  <tromey@adacore.com>
+
+       * gdb_bfd.c (gdb_bfd_open): Call bfd_fopen when fstat fails.
+
 2020-09-08  Tom Tromey  <tromey@adacore.com>
 
        PR win32/25302:
index 15bf9f79c2038933b84175e1ead398f178687779..58d177cf7df26ec8da2c6db0029c8fc6372a2ed4 100644 (file)
@@ -445,9 +445,11 @@ gdb_bfd_open (const char *name, const char *target, int fd,
       /* Weird situation here -- don't cache if we can't stat.  */
       if (debug_bfd_cache)
        fprintf_unfiltered (gdb_stdlog,
-                           "Could not stat bfd %s for %s - not caching\n",
-                           host_address_to_string (abfd),
-                           bfd_get_filename (abfd));
+                           "Could not stat %s - not caching\n",
+                           name);
+      abfd = bfd_fopen (name, target, FOPEN_RB, fd);
+      if (abfd == nullptr)
+       return nullptr;
       return gdb_bfd_ref_ptr::new_reference (abfd);
     }