summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-08-11 11:59:06 -0600
committerTom Tromey <tromey@adacore.com>2022-08-31 11:03:40 -0600
commitc3d4b6a6d9f382d7b88c2d25a1520acc1c3d51bd (patch)
tree0f56e84f5dbb87b72112e6753a63671d1306ea60
parentd9f95811860d9b99d539deb80bc6f48f0cee10e8 (diff)
downloadbinutils-gdb-c3d4b6a6d9f382d7b88c2d25a1520acc1c3d51bd.tar.gz
Use scoped_restore in safe_parse_type
This changes safe_parse_type to use scoped_restore rather than explicit assignments.
-rw-r--r--gdb/gdbtypes.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 8c2558dd7ac..c458b204157 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3168,12 +3168,11 @@ check_typedef (struct type *type)
static struct type *
safe_parse_type (struct gdbarch *gdbarch, const char *p, int length)
{
- struct ui_file *saved_gdb_stderr;
struct type *type = NULL; /* Initialize to keep gcc happy. */
/* Suppress error messages. */
- saved_gdb_stderr = gdb_stderr;
- gdb_stderr = &null_stream;
+ scoped_restore saved_gdb_stderr = make_scoped_restore (&gdb_stderr,
+ &null_stream);
/* Call parse_and_eval_type() without fear of longjmp()s. */
try
@@ -3185,9 +3184,6 @@ safe_parse_type (struct gdbarch *gdbarch, const char *p, int length)
type = builtin_type (gdbarch)->builtin_void;
}
- /* Stop suppressing error messages. */
- gdb_stderr = saved_gdb_stderr;
-
return type;
}