]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Change return type of ui_out redirect to void
authorSimon Marchi <simon.marchi@ericsson.com>
Tue, 10 Jan 2017 16:30:47 +0000 (11:30 -0500)
committerSimon Marchi <simon.marchi@ericsson.com>
Tue, 10 Jan 2017 16:32:04 +0000 (11:32 -0500)
All implementations of redirect/do_redirect in the ui_out subsystem
always return 0 (success).  We can therefore clean it up and make them
return void.

gdb/ChangeLog:

* cli-out.c (cli_ui_out::do_redirect): Change return type to
void.
* cli-out.h (cli_ui_out::do_redirect): Likewise.
* mi/mi-out.c (mi_ui_out::do_redirect): Likewise.
* mi/mi-out.h (mi_ui_out::do_redirect): Likewise.
* ui-out.c (ui_out::redirect): Likewise.
* ui-out.h (ui_out::redirect, ui_out::do_redirect): Likewise.
* cli/cli-logging.c (set_logging_redirect): Update call site of
ui_out::redirect.
(handle_redirections): Likewise.
* scm-ports.c (ioscm_with_output_to_port_worker): Likewise.
* top.c (execute_command_to_string): Likewise.
* utils.c (do_ui_out_redirect_pop): Likewise.

gdb/ChangeLog
gdb/cli-out.c
gdb/cli-out.h
gdb/cli/cli-logging.c
gdb/guile/scm-ports.c
gdb/mi/mi-out.c
gdb/mi/mi-out.h
gdb/top.c
gdb/ui-out.c
gdb/ui-out.h
gdb/utils.c

index 4733d8d04b33f3aa81ae33e21d7c5f4fa5bd1ed7..3ea58ba6c1cb17927cea1752ad8b2b9c6e1cc562 100644 (file)
@@ -1,3 +1,19 @@
+2017-01-10  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * cli-out.c (cli_ui_out::do_redirect): Change return type to
+       void.
+       * cli-out.h (cli_ui_out::do_redirect): Likewise.
+       * mi/mi-out.c (mi_ui_out::do_redirect): Likewise.
+       * mi/mi-out.h (mi_ui_out::do_redirect): Likewise.
+       * ui-out.c (ui_out::redirect): Likewise.
+       * ui-out.h (ui_out::redirect, ui_out::do_redirect): Likewise.
+       * cli/cli-logging.c (set_logging_redirect): Update call site of
+       ui_out::redirect.
+       (handle_redirections): Likewise.
+       * scm-ports.c (ioscm_with_output_to_port_worker): Likewise.
+       * top.c (execute_command_to_string): Likewise.
+       * utils.c (do_ui_out_redirect_pop): Likewise.
+
 2017-01-10  Simon Marchi  <simon.marchi@ericsson.com>
 
        * stack.c (_initialize_stack): Update "frame" command help message.
index fcb9ca1e2a7a7ff5d94dba4d45e4ce1f549ede67..2a598697a2cbf0057746e2323bc8ddecdbef252c 100644 (file)
@@ -227,15 +227,13 @@ cli_ui_out::do_flush ()
    and make it therefore active.  OUTSTREAM as NULL will pop the last pushed
    output stream; it is an internal error if it does not exist.  */
 
-int
+void
 cli_ui_out::do_redirect (ui_file *outstream)
 {
   if (outstream != NULL)
     m_streams.push_back (outstream);
   else
     m_streams.pop_back ();
-
-  return 0;
 }
 
 /* local functions */
index cc6679fefbecc95aed0671ec3ee5f7696b4923e0..1b6a1ade81211e054131194acdfebdc9865a19e4 100644 (file)
@@ -60,7 +60,7 @@ protected:
     ATTRIBUTE_PRINTF (2,0);
   virtual void do_wrap_hint (const char *identstring) override;
   virtual void do_flush () override;
-  virtual int do_redirect (struct ui_file * outstream) override;
+  virtual void do_redirect (struct ui_file *outstream) override;
 
   bool suppress_output ()
   { return m_suppress_output; }
index 884073634c1d59b4e0abb6c7cce9fe7ee5ff30dd..9428624b8addf1c44fb6288ce3dfb7ca74e9a8a6 100644 (file)
@@ -130,13 +130,11 @@ set_logging_redirect (char *args, int from_tty, struct cmd_list_element *c)
 
   /* There is a former output pushed on the ui_out_redirect stack.  We
      want to replace it by OUTPUT so we must pop the former value
-     first.  We should either do both the pop and push or to do
-     neither of it.  At least do not try to push OUTPUT if the pop
-     already failed.  */
+     first.  Ideally, we should either do both the pop and push or do
+     neither of them.  */
 
-  if (uiout->redirect (NULL) < 0
-      || uiout->redirect (output) < 0)
-    warning (_("Current output protocol does not support redirection"));
+  uiout->redirect (NULL);
+  uiout->redirect (output);
 
   do_cleanups (cleanups);
 }
@@ -246,10 +244,7 @@ handle_redirections (int from_tty)
 
   /* Don't do the redirect for MI, it confuses MI's ui-out scheme.  */
   if (!current_uiout->is_mi_like_p ())
-    {
-      if (current_uiout->redirect (output) < 0)
-       warning (_("Current output protocol does not support redirection"));
-    }
+    current_uiout->redirect (output);
 }
 
 static void
index 475e4e971dbe63665bcad66d9fa5e1132268239d..4a1c86435bcb65ed03a58d49707543dc61632ef9 100644 (file)
@@ -531,10 +531,8 @@ ioscm_with_output_to_port_worker (SCM port, SCM thunk, enum oport oport,
     gdb_stderr = port_file;
   else
     {
-      if (current_uiout->redirect (port_file) < 0)
-       warning (_("Current output protocol does not support redirection"));
-      else
-       make_cleanup_ui_out_redirect_pop (current_uiout);
+      current_uiout->redirect (port_file);
+      make_cleanup_ui_out_redirect_pop (current_uiout);
 
       gdb_stdout = port_file;
     }
index 28e1fbee089181bc5e3582d9a9b99c5b69ffc53c..5a5aef95d6c48ff2a4834d3059facdbd9b6eac60 100644 (file)
@@ -170,15 +170,13 @@ mi_ui_out::do_flush ()
   gdb_flush (m_streams.back ());
 }
 
-int
+void
 mi_ui_out::do_redirect (ui_file *outstream)
 {
   if (outstream != NULL)
     m_streams.push_back (outstream);
   else
     m_streams.pop_back ();
-
-  return 0;
 }
 
 void
index afa0b661f7e1a1cbfbf80e95e92f1261bd89e8f2..e82d44d2cec7805deae88156802d25ad5166df36 100644 (file)
@@ -67,7 +67,7 @@ protected:
     ATTRIBUTE_PRINTF (2,0);
   virtual void do_wrap_hint (const char *identstring) override;
   virtual void do_flush () override;
-  virtual int do_redirect (struct ui_file * outstream) override;
+  virtual void do_redirect (struct ui_file *outstream) override;
 
   virtual bool do_is_mi_like_p () override
   { return true; }
index 24ea14e226ae600f97b53f19f186d581827caee3..ef8d8565d3dc77459119efad241fa31511e9059b 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -706,10 +706,8 @@ execute_command_to_string (char *p, int from_tty)
 
   make_cleanup_ui_file_delete (str_file);
 
-  if (current_uiout->redirect (str_file) < 0)
-    warning (_("Current output protocol does not support redirection"));
-  else
-    make_cleanup_ui_out_redirect_pop (current_uiout);
+  current_uiout->redirect (str_file);
+  make_cleanup_ui_out_redirect_pop (current_uiout);
 
   scoped_restore save_stdout
     = make_scoped_restore (&gdb_stdout, str_file);
index 1900965923f8b7f62afae8c6718c7ee399d6fed0..fdcd45499d0ca91b76306aa72666ab5dca4c1266 100644 (file)
@@ -619,10 +619,10 @@ ui_out::flush ()
   do_flush ();
 }
 
-int
+void
 ui_out::redirect (ui_file *outstream)
 {
-  return do_redirect (outstream);
+  do_redirect (outstream);
 }
 
 /* Test the flags against the mask given.  */
index cd43cd05677d418dfe04fcbd5a10b1402bbff613..b8bea97d45f9bebe93974a6954719087ceed70cb 100644 (file)
@@ -121,7 +121,7 @@ class ui_out
   void flush ();
 
   /* Redirect the output of a ui_out object temporarily.  */
-  int redirect (ui_file *outstream);
+  void redirect (ui_file *outstream);
 
   ui_out_flags test_flags (ui_out_flags mask);
 
@@ -163,7 +163,7 @@ class ui_out
     ATTRIBUTE_PRINTF (2,0) = 0;
   virtual void do_wrap_hint (const char *identstring) = 0;
   virtual void do_flush () = 0;
-  virtual int do_redirect (struct ui_file * outstream) = 0;
+  virtual void do_redirect (struct ui_file *outstream) = 0;
 
   /* Set as not MI-like by default.  It is overridden in subclasses if
      necessary.  */
index 34e10d37d064c06e5d74559d8b26a90e1f0fa270..a6d2033727e1a6afab08db3a5f4ed72df48ae002 100644 (file)
@@ -218,8 +218,7 @@ do_ui_out_redirect_pop (void *arg)
 {
   struct ui_out *uiout = (struct ui_out *) arg;
 
-  if (uiout->redirect (NULL) < 0)
-    warning (_("Cannot restore redirection of the current output protocol"));
+  uiout->redirect (NULL);
 }
 
 /* Return a new cleanup that pops the last redirection by ui_out_redirect