This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: make execute_control_command conform to docs
- From: Dave Allan <da_gdb at egenera dot com>
- To: Andrew Cagney <cagney at gnu dot org>
- Cc: GDB patches <gdb-patches at sources dot redhat dot com>
- Date: 24 Feb 2004 16:46:36 -0500
- Subject: Re: make execute_control_command conform to docs
- Organization: Egenera, Inc.
- References: <1077640948.1311.61.camel@hasufel.egenera.com> <403BB5AD.9040502@gnu.org>
- Reply-to: da_gdb at egenera dot com
I was trying to make the patch as small as possible, but I ought to have
done it as you say. Letting everything flow through to the end so that
there is only one return point is definitely the cleanest way to do it.
Dave
On Tue, 2004-02-24 at 15:35, Andrew Cagney wrote:
> >
> > Index: cli-script.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/cli/cli-script.c,v
> > retrieving revision 1.21
> > diff -u -r1.21 cli-script.c
> > --- cli-script.c 22 Dec 2003 03:43:19 -0000 1.21
> > +++ cli-script.c 24 Feb 2004 15:55:06 -0000
> > @@ -294,7 +294,7 @@
> > {
> > struct expression *expr;
> > struct command_line *current;
> > - struct cleanup *old_chain = 0;
> > + struct cleanup *old_chain = make_cleanup (null_cleanup, 0);
> > struct value *val;
> > struct value *val_mark;
> > int loop;
> > @@ -427,8 +427,7 @@
> > return invalid_control;
> > }
> >
> > - if (old_chain)
> > - do_cleanups (old_chain);
> > + do_cleanups (old_chain);
> >
> > return ret;
> > }
>
> Close,
>
> Paths where the function explicitly does a "return" such as this:
>
> default:
> warning ("Invalid control type in command structure.");
> return invalid_control;
>
> should cleanup (or better? let things flow to the end), and this:
>
> struct cleanup *old_chain = make_cleanup (null_cleanup, 0);
> ...
> old_chain = make_cleanup (free_current_contents, &new_line);
>
> leaves a dangling cleanup (it is eventually processed but I'm not sure
> where).
>
> I'll re-arange the relevant code.
>
> Andrew
>
> PS: Remember to include a ChangeLog entry in patches.
>