From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id A3FE93857C4C; Wed, 31 Aug 2022 17:14:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3FE93857C4C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1661966085; bh=haruzVrtkUaB2XlFVK8olkuHK72QtBRP/XmdVAAqbcg=; h=From:To:Subject:Date:From; b=fl09202lsouYxe8o87dG+mW8AtFam6g9PLWIirNJNxrF0fKukolyfuexJuwW8E4Z/ Yg6fScc68ASJzFgmjNKPxfO6IReVeRROcZijNDTBhowc8vUnlx7UO7VtgYFy7xjiO0 /uF9wb6CSwYaVT+eN4IKK0usl/uo994DVGqxnPD8= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Use scoped_restore in safe_parse_type X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: d9f95811860d9b99d539deb80bc6f48f0cee10e8 X-Git-Newrev: c3d4b6a6d9f382d7b88c2d25a1520acc1c3d51bd Message-Id: <20220831171445.A3FE93857C4C@sourceware.org> Date: Wed, 31 Aug 2022 17:14:45 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dc3d4b6a6d9f3= 82d7b88c2d25a1520acc1c3d51bd commit c3d4b6a6d9f382d7b88c2d25a1520acc1c3d51bd Author: Tom Tromey Date: Thu Aug 11 11:59:06 2022 -0600 Use scoped_restore in safe_parse_type =20 This changes safe_parse_type to use scoped_restore rather than explicit assignments. Diff: --- gdb/gdbtypes.c | 8 ++------ 1 file 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 =3D NULL; /* Initialize to keep gcc happy. */ =20 /* Suppress error messages. */ - saved_gdb_stderr =3D gdb_stderr; - gdb_stderr =3D &null_stream; + scoped_restore saved_gdb_stderr =3D make_scoped_restore (&gdb_stderr, + &null_stream); =20 /* 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 =3D builtin_type (gdbarch)->builtin_void; } =20 - /* Stop suppressing error messages. */ - gdb_stderr =3D saved_gdb_stderr; - return type; }