This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: make execute_control_command conform to docs


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.
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]