From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2732 invoked by alias); 29 Oct 2008 17:39:52 -0000 Received: (qmail 2724 invoked by uid 22791); 29 Oct 2008 17:39:52 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 29 Oct 2008 17:39:49 +0000 Received: (qmail 6188 invoked from network); 29 Oct 2008 17:39:47 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 29 Oct 2008 17:39:47 -0000 From: Pedro Alves To: tromey@redhat.com Subject: Re: RFA: open-related cleanup handling Date: Wed, 29 Oct 2008 21:02:00 -0000 User-Agent: KMail/1.9.9 References: In-Reply-To: Cc: gdb-patches@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200810291740.14621.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-10/txt/msg00693.txt.bz2 On Tuesday 28 October 2008 19:59:55, Tom Tromey wrote: > Ok? Looks OK to me. > @@ -1553,24 +1556,21 @@ forward_search_command (char *regex, int from_tty) > desc = open_source_file (current_source_symtab); > if (desc < 0) > perror_with_name (current_source_symtab->filename); > + cleanups = make_cleanup_close (desc); > > if (current_source_symtab->line_charpos == 0) > find_source_lines (current_source_symtab, desc); > > if (line < 1 || line > current_source_symtab->nlines) > - { > - close (desc); > - error (_("Expression not found")); > - } > + error (_("Expression not found")); > > if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0) > - { > - close (desc); > - perror_with_name (current_source_symtab->filename); > - } > + perror_with_name (current_source_symtab->filename); > > + discard_cleanups (cleanups); I noticed that discarding a _close cleanup is currently leaking the xmalloc'ed int used to hold the file descriptor. Fixing it should be a matter of doing something similar to make_cleanup_restore_integer (using make_my_cleanup2) from inside make_cleanup_close. Would you like to take care of that while you have your hangs dirty doing these cleaning ups? -- Pedro Alves