Simplify command window creation

make_command_window is never called when *win_info_ptr is non-NULL, so
this patch simplifies the function by removing the parameter and
having it return its result directly.  This in turn makes it more
obvious that a NULL check in show_source_disasm_command can be
removed.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

	* tui/tui-layout.c (make_command_window): Remove win_info_ptr
	parameter.  Return the new window.
	(show_source_disasm_command): Update and remove NULL check.
	(show_source_or_disasm_and_command): Update.
This commit is contained in:
Tom Tromey
2019-06-16 10:32:35 -06:00
parent ec328aa512
commit 82432e1014
2 changed files with 76 additions and 77 deletions

View File

@ -1,3 +1,10 @@
2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-layout.c (make_command_window): Remove win_info_ptr
parameter. Return the new window.
(show_source_disasm_command): Update and remove NULL check.
(show_source_or_disasm_and_command): Update.
2019-06-25 Tom Tromey <tom@tromey.com> 2019-06-25 Tom Tromey <tom@tromey.com>
* tui/tui-layout.c (init_and_make_win): Remove NULL check. * tui/tui-layout.c (init_and_make_win): Remove NULL check.

View File

@ -52,7 +52,7 @@ static void show_source_or_disasm_and_command (enum tui_layout_type);
static void make_source_or_disasm_window (struct tui_win_info **, static void make_source_or_disasm_window (struct tui_win_info **,
enum tui_win_type, enum tui_win_type,
int, int); int, int);
static void make_command_window (struct tui_win_info **, int, int); static struct tui_win_info *make_command_window (int, int);
static void make_source_window (struct tui_win_info **, int, int); static void make_source_window (struct tui_win_info **, int, int);
static void make_disasm_window (struct tui_win_info **, int, int); static void make_disasm_window (struct tui_win_info **, int, int);
static void make_data_window (struct tui_win_info **, int, int); static void make_data_window (struct tui_win_info **, int, int);
@ -540,20 +540,19 @@ prev_layout (void)
static void static struct tui_win_info *
make_command_window (struct tui_win_info **win_info_ptr, make_command_window (int height, int origin_y)
int height, int origin_y)
{ {
*win_info_ptr struct tui_win_info *result
= (struct tui_win_info *) init_and_make_win (*win_info_ptr, = (struct tui_win_info *) init_and_make_win (NULL,
CMD_WIN, CMD_WIN,
height, height,
tui_term_width (), tui_term_width (),
0, 0,
origin_y, origin_y,
DONT_BOX_WINDOW); DONT_BOX_WINDOW);
result->can_highlight = FALSE;
(*win_info_ptr)->can_highlight = FALSE; return result;
} }
@ -650,8 +649,7 @@ show_source_disasm_command (void)
tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info); tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info);
TUI_SRC_WIN->detail.source_info.has_locator = FALSE;; TUI_SRC_WIN->detail.source_info.has_locator = FALSE;;
} }
if (TUI_SRC_WIN != NULL)
{
struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
tui_show_source_content (TUI_SRC_WIN); tui_show_source_content (TUI_SRC_WIN);
@ -693,8 +691,6 @@ show_source_disasm_command (void)
tui_make_visible (&TUI_DISASM_WIN->generic); tui_make_visible (&TUI_DISASM_WIN->generic);
tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info); tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info);
} }
if (TUI_DISASM_WIN != NULL)
{
TUI_SRC_WIN->detail.source_info.has_locator = FALSE; TUI_SRC_WIN->detail.source_info.has_locator = FALSE;
TUI_DISASM_WIN->detail.source_info.has_locator = TRUE; TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
tui_make_visible (locator); tui_make_visible (locator);
@ -702,8 +698,7 @@ show_source_disasm_command (void)
tui_show_source_content (TUI_DISASM_WIN); tui_show_source_content (TUI_DISASM_WIN);
if (TUI_CMD_WIN == NULL) if (TUI_CMD_WIN == NULL)
make_command_window (&TUI_CMD_WIN, TUI_CMD_WIN = make_command_window (cmd_height,
cmd_height,
tui_term_height () - cmd_height); tui_term_height () - cmd_height);
else else
{ {
@ -716,10 +711,7 @@ show_source_disasm_command (void)
TUI_CMD_WIN->can_highlight = FALSE; TUI_CMD_WIN->can_highlight = FALSE;
tui_make_visible (&TUI_CMD_WIN->generic); tui_make_visible (&TUI_CMD_WIN->generic);
} }
if (TUI_CMD_WIN != NULL)
tui_refresh_win (&TUI_CMD_WIN->generic); tui_refresh_win (&TUI_CMD_WIN->generic);
}
}
tui_set_current_layout_to (SRC_DISASSEM_COMMAND); tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
} }
} }
@ -964,7 +956,7 @@ show_source_or_disasm_and_command (enum tui_layout_type layout_type)
if (TUI_CMD_WIN == NULL) if (TUI_CMD_WIN == NULL)
{ {
make_command_window (&TUI_CMD_WIN, cmd_height, src_height); TUI_CMD_WIN = make_command_window (cmd_height, src_height);
tui_refresh_win (&TUI_CMD_WIN->generic); tui_refresh_win (&TUI_CMD_WIN->generic);
} }
else else