This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [rfa] symfile.c - fix apparently uninitialized my_cleanups
- To: Andrew Cagney <ac131313 at cygnus dot com>
- Subject: Re: [rfa] symfile.c - fix apparently uninitialized my_cleanups
- From: Michael Snyder <msnyder at redhat dot com>
- Date: Mon, 27 Nov 2000 07:58:37 -0800
- CC: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- References: <3A220AD1.83623AC9@cygnus.com>
Andrew Cagney wrote:
>
> Hello,
>
> I think the attatched is correct. ``my_cleanups'' was always
> initialized but in a somewhat obscure way. It probably illustrates a
> better way of doing cleanups for a function - unconditionally setup the
> cleanup at the very start.
Andrew,
There's nothing wrong with your change, but since there are
probably hundreds of other functions that do things in the
same way this one did, do you want to say any more about
why it's bad? Maybe motivate a few people to follow your
example?
Michael
>
> Ok?
> Andrew
>
> ---------------------------------------------------------------
> Mon Nov 27 18:19:46 2000 Andrew Cagney <cagney@b1.cygnus.com>
>
> * symfile.c (add_symbol_file_command): Always initialize
> my_cleanup using a NULL cleanup.
>
> Index: symfile.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/symfile.c,v
> retrieving revision 1.20
> diff -p -r1.20 symfile.c
> *** symfile.c 2000/10/27 15:02:42 1.20
> --- symfile.c 2000/11/27 07:22:03
> *************** add_symbol_file_command (char *args, int
> *** 1416,1422 ****
> } sect_opts[SECT_OFF_MAX];
>
> struct section_addr_info section_addrs;
> ! struct cleanup *my_cleanups;
>
> dont_repeat ();
>
> --- 1417,1423 ----
> } sect_opts[SECT_OFF_MAX];
>
> struct section_addr_info section_addrs;
> ! struct cleanup *my_cleanups = make_cleanup (null_cleanup, NULL);
>
> dont_repeat ();
>
> *************** add_symbol_file_command (char *args, int
> *** 1452,1458 ****
> {
> /* The first argument is the file name. */
> filename = tilde_expand (arg);
> ! my_cleanups = make_cleanup (free, filename);
> }
> else
> if (argcnt == 1)
> --- 1453,1459 ----
> {
> /* The first argument is the file name. */
> filename = tilde_expand (arg);
> ! make_cleanup (free, filename);
> }
> else
> if (argcnt == 1)