aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-09-08 10:35:22 -0600
committerTom Tromey <tromey@adacore.com>2020-09-08 10:35:22 -0600
commit03b0a45f15e44da7983dffea921c0c43a19250ff (patch)
tree3ed934e41e6457cb27dc40b74725ec506e32c1b8
parent3cae444768c36314cc4acf80714461cbe0aff4e4 (diff)
downloadfsf-binutils-gdb-03b0a45f15e44da7983dffea921c0c43a19250ff.zip
fsf-binutils-gdb-03b0a45f15e44da7983dffea921c0c43a19250ff.tar.gz
fsf-binutils-gdb-03b0a45f15e44da7983dffea921c0c43a19250ff.tar.bz2
Fix uninitialized warning in gdb_bfd_open
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.
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/gdb_bfd.c8
2 files changed, 9 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 01daa99..c8d4690 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
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:
* gdb_bfd.c (gdb_bfd_data): Add "st" parameter.
(gdb_bfd_init_data): New function.
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 15bf9f7..58d177c 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -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);
}