[RFA] Remove make_cleanup_restore_target_terminal

Message ID 87vakc6nph.fsf@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey Sept. 21, 2017, 4:06 p.m. UTC
  Simon> Clang gives this warning, which seems valid to me:

Sorry about this.

Pedro> Indeed.  The field should be a scoped_restore_tmpl instead of
Pedro> a scoped_restore, and that mem-initializer above should be
Pedro> calling the scoped_restore_tmpl ctor instead of make_scoped_restore.

How's the appended?

Tom

commit c068483d29873c3bc80c8accc3f50cecae0f33d8
Author: Tom Tromey <tom@tromey.com>
Date:   Thu Sep 21 09:54:25 2017 -0600

    Change type of scoped_input_handler::m_quit_handler
    
    Simon pointed out that scoped_input_handler::m_quit_handler must have
    the correct scoped_restore_tmpl type, to avoid binding to a temporary.
    This patch fixes the problem.
    
    gdb/ChangeLog
    2017-09-21  Tom Tromey  <tom@tromey.com>
    
            * utils.c (class scoped_input_handler) <m_quit_handler>: Change
            type to scoped_restore_tmpl.
            <scoped_input_handler>: Initialize m_quit_handler directly.
  

Comments

Pedro Alves Sept. 22, 2017, 3:47 p.m. UTC | #1
On 09/21/2017 05:06 PM, Tom Tromey wrote:
> Simon> Clang gives this warning, which seems valid to me:
> 
> Sorry about this.
> 
> Pedro> Indeed.  The field should be a scoped_restore_tmpl instead of
> Pedro> a scoped_restore, and that mem-initializer above should be
> Pedro> calling the scoped_restore_tmpl ctor instead of make_scoped_restore.
> 
> How's the appended?
> 
> commit c068483d29873c3bc80c8accc3f50cecae0f33d8
> Author: Tom Tromey <tom@tromey.com>
> Date:   Thu Sep 21 09:54:25 2017 -0600
> 
>     Change type of scoped_input_handler::m_quit_handler
>     
>     Simon pointed out that scoped_input_handler::m_quit_handler must have
>     the correct scoped_restore_tmpl type, to avoid binding to a temporary.
>     This patch fixes the problem.
>     
>     gdb/ChangeLog
>     2017-09-21  Tom Tromey  <tom@tromey.com>
>     
>             * utils.c (class scoped_input_handler) <m_quit_handler>: Change
>             type to scoped_restore_tmpl.
>             <scoped_input_handler>: Initialize m_quit_handler directly.

Reviewed-by: Pedro Alves <palves@redhat.com>

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5803abf..429b8b9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@ 
+2017-09-21  Tom Tromey  <tom@tromey.com>
+
+	* utils.c (class scoped_input_handler) <m_quit_handler>: Change
+	type to scoped_restore_tmpl.
+	<scoped_input_handler>: Initialize m_quit_handler directly.
+
 2017-09-21  Simon Marchi  <simon.marchi@ericsson.com>
 
 	* nat/linux-waitpid.c (linux_debug): Add ATTRIBUTE_PRINTF.
diff --git a/gdb/utils.c b/gdb/utils.c
index 9fea0f7..41ad35f 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -904,8 +904,7 @@  class scoped_input_handler
 public:
 
   scoped_input_handler ()
-    : m_quit_handler (make_scoped_restore (&quit_handler,
-					   default_quit_handler)),
+    : m_quit_handler (&quit_handler, default_quit_handler),
       m_ui (NULL)
   {
     target_terminal::ours ();
@@ -928,7 +927,7 @@  private:
   target_terminal::scoped_restore_terminal_state m_term_state;
 
   /* Save and restore the quit handler.  */
-  scoped_restore m_quit_handler;
+  scoped_restore_tmpl<quit_handler_ftype *> m_quit_handler;
 
   /* The saved UI, if non-NULL.  */
   struct ui *m_ui;