From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 0DFED3858CDB for ; Fri, 23 Jun 2023 11:15:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0DFED3858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4041221B14; Fri, 23 Jun 2023 11:15:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1687518932; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=727q0R5Z9dSiup7v/XHVESLRLdSFXKVsV5BLkC3LWF8=; b=FKymuk0c/wgcS6SokamDjAQe5sjhdvm7ll+fsSSXqtBuRtzHpfX/uXOlSWqxgRkglTit9t LLzzBCC6zOPLStArc71IPJ1Fh4HWDetso+pj+q8vPlSI7mI6SLh8xgfYeBLaRGxQYOizRr XIbh/isTzZVJU4ZJ5bNCYPRcI/IwmOk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1687518932; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=727q0R5Z9dSiup7v/XHVESLRLdSFXKVsV5BLkC3LWF8=; b=6PgEvpBSoZkWqxMKzhSfKQuwARW4DWP3j+qjrzTuSLzD83yNTzj++Y+BTJO2cdK3aT34Wj qRAeNwhoWRRYZUDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 296A7139F7; Fri, 23 Jun 2023 11:15:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CEkKCdR+lWSBFQAAMHmgww (envelope-from ); Fri, 23 Jun 2023 11:15:32 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 4/4] [gdb/tui] Make translate return entry->value instead of entry Date: Fri, 23 Jun 2023 13:15:36 +0200 Message-Id: <20230623111536.1623-4-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230623111536.1623-1-tdevries@suse.de> References: <20230623111536.1623-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The only use of "entry = translate (...)" is entry->value. Simplify using the function by returning entry->value instead. Tested on x86_64-linux. --- gdb/tui/tui-win.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) 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 -- 2.35.3