public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 2/3] [gdb/tui] Fix buglet in set_border_kind_item
Date: Mon,  8 May 2023 16:10:35 +0200	[thread overview]
Message-ID: <20230508141036.22723-3-tdevries@suse.de> (raw)
In-Reply-To: <20230508141036.22723-1-tdevries@suse.de>

While factoring out set_border_kind_item I noticed a buglet:
...
  struct tui_translate *entry = translate (key, dict);

  if (*lval != (chtype) entry->value)
    {
      *lval = (entry->value < 0) ? acs : entry->value;
...

When assigning the new value to *lval, an entry->value of -1 is taken into
account, but not when comparing to the current value of *lval.

Fix this by introducing:
...
  int val = (entry->value < 0) ? acs : entry->value;
...
and using this in both comparison and assignment.

Tested on x86_64-linux.
---
 gdb/tui/tui-win.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index cf4cb920524..fedcac4b560 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -300,10 +300,11 @@ set_border_kind_item (chtype *lval, const char *key,
 		      struct tui_translate *dict, int acs, bool *lval_changed)
 {
   struct tui_translate *entry = translate (key, dict);
+  int val = (entry->value < 0) ? acs : entry->value;
 
-  if (*lval != (chtype) entry->value)
+  if (*lval != (chtype) val)
     {
-      *lval = (entry->value < 0) ? acs : entry->value;
+      *lval = val;
       *lval_changed = true;
     }
 }
-- 
2.35.3


  parent reply	other threads:[~2023-05-08 14:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-08 14:10 [PATCH 0/3] [gdb/tui] Add tui border-kind active-ascii Tom de Vries
2023-05-08 14:10 ` [PATCH 1/3] [gdb/tui] Make tui_update_variables more readable Tom de Vries
2023-12-15 19:48   ` Tom Tromey
2023-05-08 14:10 ` Tom de Vries [this message]
2023-05-22 14:47   ` [pushed] [gdb/tui] Fix buglet in tui_update_variables Tom de Vries
2023-05-08 14:10 ` [PATCH 3/3] [gdb/tui] Add tui border-kind active-ascii Tom de Vries
2023-12-15 19:50   ` Tom Tromey
2023-12-15 20:04     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230508141036.22723-3-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).