From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25851 invoked by alias); 24 Feb 2004 21:51:30 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 25842 invoked from network); 24 Feb 2004 21:51:28 -0000 Received: from unknown (HELO coyote.egenera.com) (63.160.166.46) by sources.redhat.com with SMTP; 24 Feb 2004 21:51:28 -0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by coyote.egenera.com (Postfix) with ESMTP id C0380A051A; Tue, 24 Feb 2004 16:37:33 -0500 (EST) Received: from coyote.egenera.com ([127.0.0.1]) by localhost (coyote.egenera.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26223-04; Tue, 24 Feb 2004 16:37:30 -0500 (EST) Received: from hasufel.egenera.com (southeast.egenera.com [63.160.166.4]) by coyote.egenera.com (Postfix) with ESMTP id 2EF15A0520; Tue, 24 Feb 2004 16:37:25 -0500 (EST) Received: from localhost (localhost.localdomain [127.0.0.1]) by hasufel.egenera.com (8.11.6/8.11.6) with ESMTP id i1OLkaZ03470; Tue, 24 Feb 2004 16:46:36 -0500 Subject: Re: make execute_control_command conform to docs From: Dave Allan Reply-To: da_gdb@egenera.com To: Andrew Cagney Cc: GDB patches In-Reply-To: <403BB5AD.9040502@gnu.org> References: <1077640948.1311.61.camel@hasufel.egenera.com> <403BB5AD.9040502@gnu.org> Content-Type: text/plain Organization: Egenera, Inc. Message-Id: <1077659195.1310.192.camel@hasufel.egenera.com> Mime-Version: 1.0 Date: Tue, 24 Feb 2004 21:51:00 -0000 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at egenera.com X-SW-Source: 2004-02/txt/msg00699.txt.bz2 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. >