From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org, tromey@redhat.com
Subject: Re: RFA: cleanups -vs- gdb_fopen
Date: Wed, 29 Oct 2008 17:39:00 -0000 [thread overview]
Message-ID: <200810291645.56749.pedro@codesourcery.com> (raw)
In-Reply-To: <m3mygomvpj.fsf@fleche.redhat.com>
On Tuesday 28 October 2008 18:16:24, Tom Tromey wrote:
> @@ -97,6 +98,7 @@ handle_redirections (int from_tty)
> output = gdb_fopen (logging_filename, logging_overwrite ? "w" : "a");
> if (output == NULL)
> perror_with_name (_("set logging"));
> + cleanups = make_cleanup_ui_file_delete (output);
>
> /* Redirects everything to gdb_stdout while this is running. */
> if (!logging_redirect)
> @@ -112,6 +114,8 @@ handle_redirections (int from_tty)
> fprintf_unfiltered (gdb_stdout, "Redirecting output to %s.\n",
> logging_filename);
>
> + discard_cleanups (cleanups);
This one had me scratch my head a bit:
output = gdb_fopen (logging_filename, logging_overwrite ? "w" : "a");
if (output == NULL)
perror_with_name (_("set logging"));
+ cleanups = make_cleanup_ui_file_delete (output);
/* Redirects everything to gdb_stdout while this is running. */
if (!logging_redirect)
{
output = tee_file_new (gdb_stdout, 0, output, 1);
^^^^^^ ^
if (output == NULL)
perror_with_name (_("set logging"));
if (from_tty)
fprintf_unfiltered (gdb_stdout, "Copying output to %s.\n",
logging_filename);
}
else if (from_tty)
fprintf_unfiltered (gdb_stdout, "Redirecting output to %s.\n",
logging_filename);
+ discard_cleanups (cleanups);
If an error is thrown after tee_file_new returning a valid file (it
always does currently), you'd run the cleanup on the old `output',
and leave the new `output' leaking. That can't happen with the current
code, so, your patch looks good to me.
Thanks.
--
Pedro Alves
next prev parent reply other threads:[~2008-10-29 16:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-28 18:43 Tom Tromey
2008-10-29 17:39 ` Pedro Alves [this message]
2008-10-30 21:52 ` Tom Tromey
2008-10-30 21:35 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200810291645.56749.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox