Re: [RFA 12/23] More uses of scoped_restore

Pedro Alves
2017-06-02T18:31:50Z

On 05/03/2017 11:46 PM, Tom Tromey wrote:

> @@ -8635,7 +8614,8 @@ remote_serial_write (const char *str, int len)
> struct remote_state *rs = get_remote_state ();
> struct cleanup *old_chain;

This cleanup variable can be removed.

>
> - old_chain = make_cleanup_override_quit_handler (remote_serial_quit_handler);
> + scoped_restore restore_quit
> + = make_scoped_restore (&quit_handler, remote_serial_quit_handler);
>
> rs->got_ctrlc_during_io = 0;
>

> @@ -56,12 +47,11 @@ exec_reverse_once (const char *cmd, char *args, int from_tty)
> if (!target_can_execute_reverse)
> error (_("Target %s does not support this command."), target_shortname);
>
> - reverse_command = xstrprintf ("%s %s", cmd, args ? args : "");
> - old_chain = make_cleanup (exec_direction_default, NULL);
> - make_cleanup (xfree, reverse_command);
> + std::string reverse_command = string_printf ("%s %s", cmd, args ? args : "");
> + scoped_restore restore_exec_dir
> + = make_scoped_restore (&execution_direction, EXEC_REVERSE);
> execution_direction = EXEC_REVERSE;

This assignment is now unnecessary.

OK with those changes.

Thanks,
Pedro Alves