[34/66] Change tui_update_source_window for better type safety

Message ID 20190623224329.16060-35-tom@tromey.com
State New
Headers show
Series
  • Clean up the TUI
Related show

Commit Message

Tom Tromey June 23, 2019, 10:42 p.m.
tui_update_source_window can only be called for source and disassembly
windows, so change the argument type to enforce this at compile time.

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.h (tui_update_source_window)
	(tui_update_source_window_as_is): Change parameter type.
	* tui/tui-winsource.c (tui_update_source_window): Change win_info
	to be a tui_source_window_base.
	(tui_update_source_window_as_is): Likewise.
	* tui/tui-win.c (make_visible_with_new_height): Update.
---
 gdb/ChangeLog           | 9 +++++++++
 gdb/tui/tui-win.c       | 4 ++--
 gdb/tui/tui-winsource.c | 7 +++----
 gdb/tui/tui-winsource.h | 4 ++--
 4 files changed, 16 insertions(+), 8 deletions(-)

-- 
2.17.2

Patch

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index a40e6c5206b..c8fd267f362 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1327,7 +1327,7 @@  make_visible_with_new_height (struct tui_win_info *win_info)
 
 	  line_or_addr = base->start_line_or_addr;
 	  tui_free_win_content (win_info);
-	  tui_update_source_window (win_info, gdbarch,
+	  tui_update_source_window (base, gdbarch,
 				    cursal.symtab, line_or_addr, TRUE);
 	}
       else if (deprecated_safe_get_selected_frame () != NULL)
@@ -1349,7 +1349,7 @@  make_visible_with_new_height (struct tui_win_info *win_info)
 	      line.loa = LOA_ADDRESS;
 	      find_line_pc (s, cursal.line, &line.u.addr);
 	    }
-	  tui_update_source_window (win_info, gdbarch, s, line, TRUE);
+	  tui_update_source_window (base, gdbarch, s, line, TRUE);
 	}
       if (win_info->has_locator ())
 	{
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 254c7e00dcb..1ec9cecdc9c 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -69,14 +69,13 @@  tui_display_main ()
 /* Function to display source in the source window.  This function
    initializes the horizontal scroll to 0.  */
 void
-tui_update_source_window (struct tui_win_info *win_info,
+tui_update_source_window (struct tui_source_window_base *win_info,
 			  struct gdbarch *gdbarch,
 			  struct symtab *s,
 			  struct tui_line_or_address line_or_addr,
 			  int noerror)
 {
-  tui_source_window_base *base = (tui_source_window_base *) win_info;
-  base->horizontal_offset = 0;
+  win_info->horizontal_offset = 0;
   tui_update_source_window_as_is (win_info, gdbarch, s, line_or_addr, noerror);
 
   return;
@@ -86,7 +85,7 @@  tui_update_source_window (struct tui_win_info *win_info,
 /* Function to display source in the source/asm window.  This function
    shows the source as specified by the horizontal offset.  */
 void
-tui_update_source_window_as_is (struct tui_win_info *win_info, 
+tui_update_source_window_as_is (struct tui_source_window_base *win_info, 
 				struct gdbarch *gdbarch,
 				struct symtab *s,
 				struct tui_line_or_address line_or_addr, 
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index ada3964ad1a..6f2dc3533f7 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -39,11 +39,11 @@  extern int tui_update_breakpoint_info (struct tui_win_info *win,
 
 /* Function to display the "main" routine.  */
 extern void tui_display_main (void);
-extern void tui_update_source_window (struct tui_win_info *, 
+extern void tui_update_source_window (struct tui_source_window_base *, 
 				      struct gdbarch *, struct symtab *,
 				      struct tui_line_or_address, 
 				      int);
-extern void tui_update_source_window_as_is (struct tui_win_info *,
+extern void tui_update_source_window_as_is (struct tui_source_window_base *,
 					    struct gdbarch *, struct symtab *,
 					    struct tui_line_or_address, 
 					    int);