This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: RFA: open-related cleanup handling
- From: Pedro Alves <pedro at codesourcery dot com>
- To: tromey at redhat dot com
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 29 Oct 2008 17:40:14 +0000
- Subject: Re: RFA: open-related cleanup handling
- References: <m3fxmgmqx0.fsf@fleche.redhat.com>
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