From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Use scoped_restore in varobj.c
Date: Mon, 24 Apr 2023 12:27:11 -0600 [thread overview]
Message-ID: <20230424182711.726180-1-tromey@adacore.com> (raw)
One spot in varobj.c should use scoped_restore to save and restore
input_radix. Note that the current code may fail to restore it on
error, so this patch fixes a latent bug.
---
gdb/varobj.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 2c35b911bad..5a5e55c2d82 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -970,12 +970,12 @@ varobj_set_value (struct varobj *var, const char *expression)
We need to first construct a legal expression for this -- ugh! */
/* Does this cover all the bases? */
struct value *value = NULL; /* Initialize to keep gcc happy. */
- int saved_input_radix = input_radix;
const char *s = expression;
gdb_assert (varobj_editable_p (var));
- input_radix = 10; /* ALWAYS reset to decimal temporarily. */
+ /* ALWAYS reset to decimal temporarily. */
+ auto save_input_radix = make_scoped_restore (&input_radix, 10);
expression_up exp = parse_exp_1 (&s, 0, 0, 0);
try
{
@@ -1022,7 +1022,6 @@ varobj_set_value (struct varobj *var, const char *expression)
'updated' flag. There's no need to optimize that, because return value
of -var-update should be considered an approximation. */
var->updated = install_new_value (var, val, false /* Compare values. */);
- input_radix = saved_input_radix;
return true;
}
--
2.39.1
next reply other threads:[~2023-04-24 18:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-24 18:27 Tom Tromey [this message]
2023-04-24 19:35 ` Simon Marchi
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=20230424182711.726180-1-tromey@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/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).