From: Andrew Cagney Date: Tue, 16 May 2000 02:43:39 +0000 (+0000) Subject: Cleanup bfd_close() cleanups. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5c65bbb629ce9dcc1adf006de891208291d796d7;p=binutils-gdb.git Cleanup bfd_close() cleanups. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f8342fa46c0..085add88638 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 adcfe90df19..6cdf0d7497f 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 aa8987dda56..390da352e08 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 c5ced876caf..608f116c502 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 12590f88111..9a377a071a3 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 b6ea064cf97..91499af03f6 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 b01fe33f712..8fc4fe7c962 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 aa1fccd2853..3fd055caad9 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) {