From: Tom Tromey Date: Sun, 14 Oct 2018 18:50:32 +0000 (-0600) Subject: Remove unnecessary casts from TUI X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=63a33118e05a84fbae40cbe3ef955b52bad359a7;p=binutils-gdb.git Remove unnecessary casts from TUI This removes a number of unnecessary casts from the TUI. Some were found with -Wuseless-cast (which, I think, can't easily be enabled for gdb); and some were found by inspection. Tested by rebuilding on x86-64 Fedora 28. I'm checking this in. gdb/ChangeLog 2018-10-15 Tom Tromey * tui/tui.c (strcat_to_buf): Remove casts. * tui/tui-winsource.c (tui_show_source_line) (tui_set_is_exec_point_at, tui_line_is_displayed): Remove casts. * tui/tui-wingeneral.c (tui_refresh_win, box_win): Remove casts. * tui/tui-windata.c (tui_first_data_item_displayed) (tui_delete_data_content_windows, tui_erase_data_content) (tui_display_all_data, tui_display_data_from) (tui_refresh_data_win, tui_vertical_data_scroll): Remove casts. * tui/tui-win.c (tui_set_win_height) (make_invisible_and_set_new_height, parse_scrolling_args): Remove casts. * tui/tui-win.c (tui_resize_all): Remove casts. (tui_scroll_backward_command, tui_set_focus) (tui_set_tab_width_command): Likewise. * tui/tui-source.c (tui_vertical_source_scroll): Remove cast. * tui/tui-regs.c (tui_show_register_group): Remove cast. * tui/tui-layout.c (tui_set_layout_by_name): Remove cast. * tui/tui-disasm.c (tui_vertical_disassem_scroll): Remove cast. * tui/tui-data.c (tui_partial_win_by_name, tui_free_win_content): Remove casts. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8c887ef33a8..03fb785d9a1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,26 @@ +2018-10-15 Tom Tromey + + * tui/tui.c (strcat_to_buf): Remove casts. + * tui/tui-winsource.c (tui_show_source_line) + (tui_set_is_exec_point_at, tui_line_is_displayed): Remove casts. + * tui/tui-wingeneral.c (tui_refresh_win, box_win): Remove casts. + * tui/tui-windata.c (tui_first_data_item_displayed) + (tui_delete_data_content_windows, tui_erase_data_content) + (tui_display_all_data, tui_display_data_from) + (tui_refresh_data_win, tui_vertical_data_scroll): Remove casts. + * tui/tui-win.c (tui_set_win_height) + (make_invisible_and_set_new_height, parse_scrolling_args): Remove + casts. + * tui/tui-win.c (tui_resize_all): Remove casts. + (tui_scroll_backward_command, tui_set_focus) + (tui_set_tab_width_command): Likewise. + * tui/tui-source.c (tui_vertical_source_scroll): Remove cast. + * tui/tui-regs.c (tui_show_register_group): Remove cast. + * tui/tui-layout.c (tui_set_layout_by_name): Remove cast. + * tui/tui-disasm.c (tui_vertical_disassem_scroll): Remove cast. + * tui/tui-data.c (tui_partial_win_by_name, tui_free_win_content): + Remove casts. + 2018-10-15 Simon Marchi * MAINTAINERS (Responsible Maintainers): Add Alan Hayward as diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 7dbd1475ee0..66693afe964 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -375,7 +375,7 @@ tui_partial_win_by_name (const char *name) { struct tui_win_info *win_info = NULL; - if (name != (char *) NULL) + if (name != NULL) { int i = 0; @@ -766,7 +766,7 @@ tui_free_win_content (struct tui_gen_win_info *win_info) { if (win_info->content != NULL) { - free_content ((tui_win_content) win_info->content, + free_content (win_info->content, win_info->content_size, win_info->type); win_info->content = NULL; diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index dd61d1e77c9..1bbfd1e9819 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -384,7 +384,7 @@ tui_vertical_disassem_scroll (enum tui_scroll_direction scroll_direction, struct tui_line_or_address val; int dir; - content = (tui_win_content) TUI_DISASM_WIN->generic.content; + content = TUI_DISASM_WIN->generic.content; pc = content[0]->which_element.source.line_or_addr.u.addr; num_to_scroll++; diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 66e8e45f376..8186f75b582 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -401,7 +401,7 @@ tui_set_layout_by_name (const char *layout_name) { enum tui_status status = TUI_SUCCESS; - if (layout_name != (char *) NULL) + if (layout_name != NULL) { int i; enum tui_layout_type new_layout = UNDEFINED_LAYOUT; diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index 7059b02ff38..12382cddb35 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -247,8 +247,7 @@ tui_show_register_group (struct reggroup *group, TUI_DATA_WIN->generic.content = NULL; TUI_DATA_WIN->generic.content_size = 0; tui_add_content_elements (&TUI_DATA_WIN->generic, nr_regs); - display_info->regs_content - = (tui_win_content) TUI_DATA_WIN->generic.content; + display_info->regs_content = TUI_DATA_WIN->generic.content; display_info->regs_content_count = nr_regs; } diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 49c21368123..de8b77ee854 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -351,7 +351,7 @@ tui_vertical_source_scroll (enum tui_scroll_direction scroll_direction, { struct tui_line_or_address l; struct symtab *s; - tui_win_content content = (tui_win_content) TUI_SRC_WIN->generic.content; + tui_win_content content = TUI_SRC_WIN->generic.content; struct symtab_and_line cursal = get_current_source_symtab_and_line (); if (cursal.symtab == (struct symtab *) NULL) diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 225c6e9d4b3..bcd0e541891 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -793,7 +793,7 @@ tui_resize_all (void) { case SRC_COMMAND: case DISASSEM_COMMAND: - first_win = (struct tui_win_info *) (tui_source_windows ())->list[0]; + first_win = tui_source_windows ()->list[0]; first_win->generic.width += width_diff; locator->width += width_diff; /* Check for invalid heights. */ @@ -830,8 +830,7 @@ tui_resize_all (void) { first_win = TUI_DATA_WIN; first_win->generic.width += width_diff; - second_win = (struct tui_win_info *) - (tui_source_windows ())->list[0]; + second_win = tui_source_windows ()->list[0]; second_win->generic.width += width_diff; } /* Change the first window's height/width. */ @@ -984,7 +983,7 @@ tui_scroll_forward_command (const char *arg, int from_tty) /* Make sure the curses mode is enabled. */ tui_enable (); - if (arg == (char *) NULL) + if (arg == NULL) parse_scrolling_args (arg, &win_to_scroll, (int *) NULL); else parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll); @@ -1000,7 +999,7 @@ tui_scroll_backward_command (const char *arg, int from_tty) /* Make sure the curses mode is enabled. */ tui_enable (); - if (arg == (char *) NULL) + if (arg == NULL) parse_scrolling_args (arg, &win_to_scroll, (int *) NULL); else parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll); @@ -1038,9 +1037,9 @@ tui_scroll_right_command (const char *arg, int from_tty) static void tui_set_focus (const char *arg, int from_tty) { - if (arg != (char *) NULL) + if (arg != NULL) { - char *buf_ptr = (char *) xstrdup (arg); + char *buf_ptr = xstrdup (arg); int i; struct tui_win_info *win_info = NULL; @@ -1121,7 +1120,7 @@ tui_set_tab_width_command (const char *arg, int from_tty) { /* Make sure the curses mode is enabled. */ tui_enable (); - if (arg != (char *) NULL) + if (arg != NULL) { int ts; @@ -1160,7 +1159,7 @@ tui_set_win_height (const char *arg, int from_tty) { /* Make sure the curses mode is enabled. */ tui_enable (); - if (arg != (char *) NULL) + if (arg != NULL) { std::string copy = arg; char *buf = ©[0]; @@ -1171,7 +1170,7 @@ tui_set_win_height (const char *arg, int from_tty) wname = buf_ptr; buf_ptr = strchr (buf_ptr, ' '); - if (buf_ptr != (char *) NULL) + if (buf_ptr != NULL) { *buf_ptr = (char) 0; @@ -1444,9 +1443,8 @@ make_invisible_and_set_new_height (struct tui_win_info *win_info, /* Delete all data item windows. */ for (i = 0; i < win_info->generic.content_size; i++) { - gen_win_info = (struct tui_gen_win_info *) - &((struct tui_win_element *) - win_info->generic.content[i])->which_element.data_window; + gen_win_info + = &win_info->generic.content[i]->which_element.data_window; tui_delete_win (gen_win_info->handle); gen_win_info->handle = NULL; } @@ -1653,7 +1651,7 @@ parse_scrolling_args (const char *arg, /* First set up the default window to scroll, in case there is no window name arg. */ - if (arg != (char *) NULL) + if (arg != NULL) { char *buf_ptr; @@ -1666,7 +1664,7 @@ parse_scrolling_args (const char *arg, num_str = buf_ptr; buf_ptr = strchr (buf_ptr, ' '); - if (buf_ptr != (char *) NULL) + if (buf_ptr != NULL) { *buf_ptr = (char) 0; if (num_to_scroll) @@ -1678,7 +1676,7 @@ parse_scrolling_args (const char *arg, } /* Process the window name if one is specified. */ - if (buf_ptr != (char *) NULL) + if (buf_ptr != NULL) { const char *wname; diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c index a7d6dff7cc1..5688cff80bb 100644 --- a/gdb/tui/tui-windata.c +++ b/gdb/tui/tui-windata.c @@ -53,8 +53,8 @@ tui_first_data_item_displayed (void) { struct tui_gen_win_info *data_item_win; - data_item_win = &((tui_win_content) - TUI_DATA_WIN->generic.content)[i]->which_element.data_window; + data_item_win + = &TUI_DATA_WIN->generic.content[i]->which_element.data_window; if (data_item_win->handle != (WINDOW *) NULL && data_item_win->is_visible) element_no = i; @@ -91,8 +91,8 @@ tui_delete_data_content_windows (void) for (i = 0; (i < TUI_DATA_WIN->generic.content_size); i++) { - data_item_win_ptr = &((tui_win_content) - TUI_DATA_WIN->generic.content)[i]->which_element.data_window; + data_item_win_ptr + = &TUI_DATA_WIN->generic.content[i]->which_element.data_window; tui_delete_win (data_item_win_ptr->handle); data_item_win_ptr->handle = NULL; data_item_win_ptr->is_visible = FALSE; @@ -105,7 +105,7 @@ tui_erase_data_content (const char *prompt) { werase (TUI_DATA_WIN->generic.handle); tui_check_and_display_highlight_if_needed (TUI_DATA_WIN); - if (prompt != (char *) NULL) + if (prompt != NULL) { int half_width = (TUI_DATA_WIN->generic.width - 2) / 2; int x_pos; @@ -132,7 +132,7 @@ tui_display_all_data (void) tui_erase_data_content (NO_DATA_STRING); else { - tui_erase_data_content ((char *) NULL); + tui_erase_data_content (NULL); tui_delete_data_content_windows (); tui_check_and_display_highlight_if_needed (TUI_DATA_WIN); tui_display_registers_from (0); @@ -201,7 +201,7 @@ tui_display_data_from (int element_no, int reuse_windows) if (first_line >= 0) { - tui_erase_data_content ((char *) NULL); + tui_erase_data_content (NULL); if (!reuse_windows) tui_delete_data_content_windows (); tui_display_data_from_line (first_line); @@ -213,7 +213,7 @@ tui_display_data_from (int element_no, int reuse_windows) void tui_refresh_data_win (void) { - tui_erase_data_content ((char *) NULL); + tui_erase_data_content (NULL); if (TUI_DATA_WIN->generic.content_size > 0) { int first_element = tui_first_data_item_displayed (); @@ -284,7 +284,7 @@ tui_vertical_data_scroll (enum tui_scroll_direction scroll_direction, first_line += num_to_scroll; else first_line -= num_to_scroll; - tui_erase_data_content ((char *) NULL); + tui_erase_data_content (NULL); tui_delete_data_content_windows (); tui_display_data_from_line (first_line); } diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c index dbe201a09c1..2d79ea39ab0 100644 --- a/gdb/tui/tui-wingeneral.c +++ b/gdb/tui/tui-wingeneral.c @@ -43,8 +43,7 @@ tui_refresh_win (struct tui_gen_win_info *win_info) { struct tui_gen_win_info *data_item_win_ptr; - data_item_win_ptr = &((tui_win_content) - win_info->content)[i]->which_element.data_window; + data_item_win_ptr = &win_info->content[i]->which_element.data_window; if (data_item_win_ptr != NULL && data_item_win_ptr->handle != (WINDOW *) NULL) wrefresh (data_item_win_ptr->handle); @@ -101,7 +100,7 @@ box_win (struct tui_gen_win_info *win_info, box (win, tui_border_vline, tui_border_hline); #endif if (win_info->title) - mvwaddstr (win, 0, 3, (char *) win_info->title); + mvwaddstr (win, 0, 3, win_info->title); wattroff (win, attrs); } } diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 6c5fe5dbec6..49eb4ce6fcb 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -279,7 +279,7 @@ tui_show_source_line (struct tui_win_info *win_info, int lineno) wattron (win_info->generic.handle, A_STANDOUT); mvwaddstr (win_info->generic.handle, lineno, 1, - (char *) line->which_element.source.line); + line->which_element.source.line); if (line->which_element.source.is_exec_point) wattroff (win_info->generic.handle, A_STANDOUT); @@ -364,7 +364,7 @@ tui_set_is_exec_point_at (struct tui_line_or_address l, { int changed = 0; int i; - tui_win_content content = (tui_win_content) win_info->generic.content; + tui_win_content content = win_info->generic.content; i = 0; while (i < win_info->generic.content_size) @@ -651,7 +651,7 @@ tui_line_is_displayed (int line, = win_info->generic.content[i] ->which_element.source.line_or_addr.loa == LOA_LINE && win_info->generic.content[i] - ->which_element.source.line_or_addr.u.line_no == (int) line; + ->which_element.source.line_or_addr.u.line_no == line; i++; } diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index 75a9ced6190..50cad22f16f 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -562,7 +562,7 @@ void strcat_to_buf (char *buf, int buflen, const char *item_to_add) { - if (item_to_add != (char *) NULL && buf != (char *) NULL) + if (item_to_add != NULL && buf != NULL) { if ((strlen (buf) + strlen (item_to_add)) <= buflen) strcat (buf, item_to_add);