Patchwork [FYI,1/2] Use "bool" in more spots in TUI

login
register
mail settings
Submitter Tom Tromey
Date Dec. 30, 2019, 4:12 p.m.
Message ID <20191230161258.20044-2-tom@tromey.com>
Download mbox | patch
Permalink /patch/37125/
State New
Headers show

Comments

Tom Tromey - Dec. 30, 2019, 4:12 p.m.
This changes a few spots in the TUI to use "bool" rather than "int".
Tested on x86-64 Fedora 28.

gdb/ChangeLog
2019-12-30  Tom Tromey  <tom@tromey.com>

	* tui/tui-interp.c (tui_start_enabled): Now bool.
	(_initialize_tui_interp): Update.
	* tui/tui-hooks.c (tui_refreshing_registers): Now bool.
	(tui_register_changed)
	(tui_refresh_frame_and_register_information): Update.
	* tui/tui-win.c (tui_update_variables): Return bool.
	* tui/tui-win.h (tui_update_variables): Return bool.
	* tui/tui.c (tui_get_command_dimension): Return bool.
	* tui/tui.h (tui_get_command_dimension): Return bool.

Change-Id: I55b7f2d62d2ef88da3587dc914ada9f463ad8d2b
---
 gdb/ChangeLog        | 12 ++++++++++++
 gdb/tui/tui-hooks.c  | 12 ++++++------
 gdb/tui/tui-interp.c |  6 +++---
 gdb/tui/tui-win.c    | 12 ++++++------
 gdb/tui/tui-win.h    |  2 +-
 gdb/tui/tui.c        |  8 +++-----
 gdb/tui/tui.h        |  4 ++--
 7 files changed, 33 insertions(+), 23 deletions(-)

Patch

diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index 8576bb8fccd..b92abb9e031 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -57,7 +57,7 @@  tui_new_objfile_hook (struct objfile* objfile)
 }
 
 /* Prevent recursion of deprecated_register_changed_hook().  */
-static int tui_refreshing_registers = 0;
+static bool tui_refreshing_registers = false;
 
 /* Observer for the register_changed notification.  */
 
@@ -75,11 +75,11 @@  tui_register_changed (struct frame_info *frame, int regno)
      up in the other.  So we always use the selected frame here, and ignore
      FRAME.  */
   fi = get_selected_frame (NULL);
-  if (tui_refreshing_registers == 0)
+  if (!tui_refreshing_registers)
     {
-      tui_refreshing_registers = 1;
+      tui_refreshing_registers = true;
       TUI_DATA_WIN->check_register_values (fi);
-      tui_refreshing_registers = 0;
+      tui_refreshing_registers = false;
     }
 }
 
@@ -139,9 +139,9 @@  tui_refresh_frame_and_register_information ()
       if (tui_is_window_visible (DATA_WIN)
 	  && (frame_info_changed_p || from_stack))
 	{
-	  tui_refreshing_registers = 1;
+	  tui_refreshing_registers = true;
 	  TUI_DATA_WIN->check_register_values (fi);
-	  tui_refreshing_registers = 0;
+	  tui_refreshing_registers = false;
 	}
     }
   else if (!from_stack)
diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c
index bc8fde363bf..01edbd0e48a 100644
--- a/gdb/tui/tui-interp.c
+++ b/gdb/tui/tui-interp.c
@@ -35,9 +35,9 @@ 
 #include "inferior.h"
 #include "main.h"
 
-/* Set to 1 when the TUI mode must be activated when we first start
+/* Set to true when the TUI mode must be activated when we first start
    gdb.  */
-static int tui_start_enabled = 0;
+static bool tui_start_enabled = false;
 
 class tui_interp final : public cli_interp_base
 {
@@ -312,7 +312,7 @@  _initialize_tui_interp (void)
   interp_factory_register (INTERP_TUI, tui_interp_factory);
 
   if (interpreter_p && strcmp (interpreter_p, INTERP_TUI) == 0)
-    tui_start_enabled = 1;
+    tui_start_enabled = true;
 
   if (interpreter_p && strcmp (interpreter_p, INTERP_CONSOLE) == 0)
     {
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index ac3690a7f45..959b0cdd76f 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -254,23 +254,23 @@  translate (const char *name, struct tui_translate *table)
 /* Update the tui internal configuration according to gdb settings.
    Returns 1 if the configuration has changed and the screen should
    be redrawn.  */
-int
-tui_update_variables (void)
+bool
+tui_update_variables ()
 {
-  int need_redraw = 0;
+  bool need_redraw = false;
   struct tui_translate *entry;
 
   entry = translate (tui_border_mode, tui_border_mode_translate);
   if (tui_border_attrs != entry->value)
     {
       tui_border_attrs = entry->value;
-      need_redraw = 1;
+      need_redraw = true;
     }
   entry = translate (tui_active_border_mode, tui_border_mode_translate);
   if (tui_active_border_attrs != entry->value)
     {
       tui_active_border_attrs = entry->value;
-      need_redraw = 1;
+      need_redraw = true;
     }
 
   /* If one corner changes, all characters are changed.
@@ -280,7 +280,7 @@  tui_update_variables (void)
   if (tui_border_lrcorner != (chtype) entry->value)
     {
       tui_border_lrcorner = (entry->value < 0) ? ACS_LRCORNER : entry->value;
-      need_redraw = 1;
+      need_redraw = true;
     }
   entry = translate (tui_border_kind, tui_border_kind_translate_llcorner);
   tui_border_llcorner = (entry->value < 0) ? ACS_LLCORNER : entry->value;
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 1ffe683107a..789a3e83240 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -44,7 +44,7 @@  extern chtype tui_border_hline;
 extern int tui_border_attrs;
 extern int tui_active_border_attrs;
 
-extern int tui_update_variables (void);
+extern bool tui_update_variables ();
 
 extern void tui_initialize_win (void);
 
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 6fdfa4579f1..f73ef7d58bf 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -591,18 +591,16 @@  tui_is_window_visible (enum tui_win_type type)
   return tui_win_list[type]->is_visible ();
 }
 
-int
+bool
 tui_get_command_dimension (unsigned int *width, 
 			   unsigned int *height)
 {
   if (!tui_active || (TUI_CMD_WIN == NULL))
-    {
-      return 0;
-    }
+    return false;
   
   *width = TUI_CMD_WIN->width;
   *height = TUI_CMD_WIN->height;
-  return 1;
+  return true;
 }
 
 void
diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h
index 14f2939fd24..75574e527c9 100644
--- a/gdb/tui/tui.h
+++ b/gdb/tui/tui.h
@@ -49,8 +49,8 @@  extern CORE_ADDR tui_get_low_disassembly_address (struct gdbarch *,
 						  CORE_ADDR, CORE_ADDR);
 extern void tui_show_assembly (struct gdbarch *gdbarch, CORE_ADDR addr);
 extern bool tui_is_window_visible (enum tui_win_type type);
-extern int tui_get_command_dimension (unsigned int *width,
-				      unsigned int *height);
+extern bool tui_get_command_dimension (unsigned int *width,
+				       unsigned int *height);
 
 /* Initialize readline and configure the keymap for the switching
    key shortcut.  */