aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-04-24 12:25:53 -0600
committerTom Tromey <tromey@adacore.com>2023-04-25 12:01:45 -0600
commitb6fc08e89f31f16059303bdca2ec9a74f89b5a05 (patch)
tree4d80dba2db70a3f825331148ccb617637d63bac9 /gdb
parentfc53c8e02183b61a9df0224de1d7016fb52960ba (diff)
downloadbinutils-b6fc08e89f31f16059303bdca2ec9a74f89b5a05.zip
binutils-b6fc08e89f31f16059303bdca2ec9a74f89b5a05.tar.gz
binutils-b6fc08e89f31f16059303bdca2ec9a74f89b5a05.tar.bz2
Use scoped_restore in varobj.c
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. Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb')
-rw-r--r--gdb/varobj.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 2c35b91..5a5e55c 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;
}