Remove cleanups from ser-mingw.c
This removes the only cleanup from ser-mingw.c, replacing it with a specialization of std::unique_ptr. Tested by the buildbot. gdb/ChangeLog 2018-06-18 Tom Tromey <tom@tromey.com> * ser-mingw.c (struct pipe_state_destroyer): New. (pipe_state_up): New typedef. (cleanup_pipe_state): Remove. (pipe_windows_open): Use pipe_state_up. Don't release argv.
This commit is contained in:
parent
69d340c684
commit
3f0dbd670b
@ -1,3 +1,10 @@
|
|||||||
|
2018-06-18 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* ser-mingw.c (struct pipe_state_destroyer): New.
|
||||||
|
(pipe_state_up): New typedef.
|
||||||
|
(cleanup_pipe_state): Remove.
|
||||||
|
(pipe_windows_open): Use pipe_state_up. Don't release argv.
|
||||||
|
|
||||||
2018-06-18 Tom Tromey <tom@tromey.com>
|
2018-06-18 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* rust-lang.h (rust_yyerror): Don't declare.
|
* rust-lang.h (rust_yyerror): Don't declare.
|
||||||
|
@ -848,20 +848,20 @@ free_pipe_state (struct pipe_state *ps)
|
|||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
struct pipe_state_destroyer
|
||||||
cleanup_pipe_state (void *untyped)
|
|
||||||
{
|
{
|
||||||
struct pipe_state *ps = (struct pipe_state *) untyped;
|
void operator() (pipe_state *ps) const
|
||||||
|
{
|
||||||
free_pipe_state (ps);
|
free_pipe_state (ps);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::unique_ptr<pipe_state, pipe_state_destroyer> pipe_state_up;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pipe_windows_open (struct serial *scb, const char *name)
|
pipe_windows_open (struct serial *scb, const char *name)
|
||||||
{
|
{
|
||||||
struct pipe_state *ps;
|
|
||||||
FILE *pex_stderr;
|
FILE *pex_stderr;
|
||||||
struct cleanup *back_to;
|
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
error_no_arg (_("child command"));
|
error_no_arg (_("child command"));
|
||||||
@ -871,15 +871,14 @@ pipe_windows_open (struct serial *scb, const char *name)
|
|||||||
if (! argv[0] || argv[0][0] == '\0')
|
if (! argv[0] || argv[0][0] == '\0')
|
||||||
error (_("missing child command"));
|
error (_("missing child command"));
|
||||||
|
|
||||||
ps = make_pipe_state ();
|
pipe_state_up ps (make_pipe_state ());
|
||||||
back_to = make_cleanup (cleanup_pipe_state, ps);
|
|
||||||
|
|
||||||
ps->pex = pex_init (PEX_USE_PIPES, "target remote pipe", NULL);
|
ps->pex = pex_init (PEX_USE_PIPES, "target remote pipe", NULL);
|
||||||
if (! ps->pex)
|
if (! ps->pex)
|
||||||
goto fail;
|
return -1;
|
||||||
ps->input = pex_input_pipe (ps->pex, 1);
|
ps->input = pex_input_pipe (ps->pex, 1);
|
||||||
if (! ps->input)
|
if (! ps->input)
|
||||||
goto fail;
|
return -1;
|
||||||
|
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
@ -906,23 +905,17 @@ pipe_windows_open (struct serial *scb, const char *name)
|
|||||||
|
|
||||||
ps->output = pex_read_output (ps->pex, 1);
|
ps->output = pex_read_output (ps->pex, 1);
|
||||||
if (! ps->output)
|
if (! ps->output)
|
||||||
goto fail;
|
return -1;
|
||||||
scb->fd = fileno (ps->output);
|
scb->fd = fileno (ps->output);
|
||||||
|
|
||||||
pex_stderr = pex_read_err (ps->pex, 1);
|
pex_stderr = pex_read_err (ps->pex, 1);
|
||||||
if (! pex_stderr)
|
if (! pex_stderr)
|
||||||
goto fail;
|
return -1;
|
||||||
scb->error_fd = fileno (pex_stderr);
|
scb->error_fd = fileno (pex_stderr);
|
||||||
|
|
||||||
scb->state = (void *) ps;
|
scb->state = ps.release ();
|
||||||
|
|
||||||
argv.release ();
|
|
||||||
discard_cleanups (back_to);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
|
||||||
do_cleanups (back_to);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user