From 5c65bbb629ce9dcc1adf006de891208291d796d7 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Tue, 16 May 2000 02:43:39 +0000 Subject: [PATCH] Cleanup bfd_close() cleanups. --- gdb/ChangeLog | 10 ++++++++++ gdb/corelow.c | 4 ++-- gdb/defs.h | 2 ++ gdb/remote-e7000.c | 2 +- gdb/remote-udi.c | 2 +- gdb/sparcl-tdep.c | 2 +- gdb/symfile.c | 2 +- gdb/utils.c | 12 ++++++++++++ 8 files changed, 30 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f8342fa46c..085add8863 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +Tue May 16 10:54:55 2000 Andrew Cagney + + * defs.h (make_cleanup_bfd_close): Add declaration. + * utils.c (do_bfd_close_cleanup, make_cleanup_bfd_close): New + functions. + + * symfile.c (generic_load), sparcl-tdep.c (download), remote-udi.c + (download), remote-e7000.c (e7000_load), corelow.c (core_open, + core_file_to_sym_file): Replace calls to make_cleanup. + Mon May 15 16:50:45 2000 Andrew Cagney * TODO: Add notes on register cache. diff --git a/gdb/corelow.c b/gdb/corelow.c index adcfe90df1..6cdf0d7497 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -295,7 +295,7 @@ core_open (filename, from_tty) /* FIXME: should be checking for errors from bfd_close (for one thing, on error it does not free all the storage associated with the bfd). */ - make_cleanup ((make_cleanup_func) bfd_close, temp_bfd); + make_cleanup_bfd_close (temp_bfd); error ("\"%s\" is not a core dump: %s", filename, bfd_errmsg (bfd_get_error ())); } @@ -493,7 +493,7 @@ core_file_to_sym_file (core) /* FIXME: should be checking for errors from bfd_close (for one thing, on error it does not free all the storage associated with the bfd). */ - make_cleanup ((make_cleanup_func) bfd_close, temp_bfd); + make_cleanup_bfd_close (temp_bfd); error ("\"%s\" is not a core dump: %s", core, bfd_errmsg (bfd_get_error ())); } diff --git a/gdb/defs.h b/gdb/defs.h index aa8987dda5..390da352e0 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -332,6 +332,8 @@ extern struct cleanup *make_cleanup_freeargv (char **); struct ui_file; extern struct cleanup *make_cleanup_ui_file_delete (struct ui_file *); +extern struct cleanup *make_cleanup_bfd_close (bfd *abfd); + extern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *); extern struct cleanup *make_my_cleanup (struct cleanup **, diff --git a/gdb/remote-e7000.c b/gdb/remote-e7000.c index c5ced876ca..608f116c50 100644 --- a/gdb/remote-e7000.c +++ b/gdb/remote-e7000.c @@ -1580,7 +1580,7 @@ e7000_load (args, from_tty) perror_with_name (filename); return; } - old_chain = make_cleanup ((make_cleanup_func) bfd_close, pbfd); + old_chain = make_cleanup_bfd_close (pbfd); if (!bfd_check_format (pbfd, bfd_object)) error ("\"%s\" is not an object file: %s", filename, diff --git a/gdb/remote-udi.c b/gdb/remote-udi.c index 12590f8811..9a377a071a 100644 --- a/gdb/remote-udi.c +++ b/gdb/remote-udi.c @@ -1162,7 +1162,7 @@ download (load_arg_string, from_tty) /* FIXME: should be checking for errors from bfd_close (for one thing, on error it does not free all the storage associated with the bfd). */ - make_cleanup ((make_cleanup_func) bfd_close, pbfd); + make_cleanup_bfd_close (pbfd); QUIT; immediate_quit++; diff --git a/gdb/sparcl-tdep.c b/gdb/sparcl-tdep.c index b6ea064cf9..91499af03f 100644 --- a/gdb/sparcl-tdep.c +++ b/gdb/sparcl-tdep.c @@ -614,7 +614,7 @@ download (target_name, args, from_tty, write_routine, start_routine) perror_with_name (filename); return; } - old_chain = make_cleanup ((make_cleanup_func) bfd_close, pbfd); + old_chain = make_cleanup_bfd_close (pbfd); if (!bfd_check_format (pbfd, bfd_object)) error ("\"%s\" is not an object file: %s", filename, diff --git a/gdb/symfile.c b/gdb/symfile.c index b01fe33f71..8fc4fe7c96 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1230,7 +1230,7 @@ generic_load (char *args, int from_tty) /* FIXME: should be checking for errors from bfd_close (for one thing, on error it does not free all the storage associated with the bfd). */ - make_cleanup ((make_cleanup_func) bfd_close, loadfile_bfd); + make_cleanup_bfd_close (loadfile_bfd); if (!bfd_check_format (loadfile_bfd, bfd_object)) { diff --git a/gdb/utils.c b/gdb/utils.c index aa1fccd285..3fd055caad 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -203,6 +203,18 @@ make_cleanup_freeargv (arg) return make_my_cleanup (&cleanup_chain, do_freeargv, arg); } +static void +do_bfd_close_cleanup (void *arg) +{ + bfd_close (arg); +} + +struct cleanup * +make_cleanup_bfd_close (bfd *abfd) +{ + return make_cleanup (do_bfd_close_cleanup, abfd); +} + static void do_ui_file_delete (void *arg) { -- 2.34.1