From: Tom de Vries Date: Wed, 12 Jul 2023 10:07:40 +0000 (+0200) Subject: [gdb/tui] Make translate return entry->value instead of entry X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=664ac93fa86a974aaf42497a58bc1c05dde09909;p=binutils-gdb.git [gdb/tui] Make translate return entry->value instead of entry The only use of "entry = translate (...)" is entry->value. Simplify using the function by returning entry->value instead. Tested on x86_64-linux. Approved-By: Tom Tromey --- diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 2cc81778f3a..93cf45ed296 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -223,14 +223,14 @@ chtype tui_border_lrcorner; int tui_border_attrs; int tui_active_border_attrs; -/* Identify the item in the translation table. */ -static struct tui_translate * +/* Identify the item in the translation table, and return the corresponding value. */ +static int translate (const char *name, struct tui_translate *table) { while (table->name) { if (name && strcmp (table->name, name) == 0) - return table; + return table->value; table++; } @@ -247,7 +247,7 @@ translate_acs (const char *name, struct tui_translate *table, int acs_char) if (strcmp (name, "acs") == 0) return acs_char; - return translate (name, table)->value; + return translate (name, table); } /* Update the tui internal configuration according to gdb settings. @@ -257,20 +257,18 @@ bool tui_update_variables () { bool need_redraw = false; - struct tui_translate *entry; + int val; - entry = translate (tui_border_mode, tui_border_mode_translate); - need_redraw - |= assign_return_if_changed (tui_border_attrs, entry->value); + val = translate (tui_border_mode, tui_border_mode_translate); + need_redraw |= assign_return_if_changed (tui_border_attrs, val); - entry = translate (tui_active_border_mode, tui_border_mode_translate); - need_redraw - |= assign_return_if_changed (tui_active_border_attrs, entry->value); + val = translate (tui_active_border_mode, tui_border_mode_translate); + need_redraw |= assign_return_if_changed (tui_active_border_attrs, val); /* If one corner changes, all characters are changed. Only check the first one. */ - int val = translate_acs (tui_border_kind, tui_border_kind_translate_corner, - ACS_LRCORNER); + val = translate_acs (tui_border_kind, tui_border_kind_translate_corner, + ACS_LRCORNER); need_redraw |= assign_return_if_changed (tui_border_lrcorner, val); tui_border_llcorner