public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Use scoped_restore in safe_parse_type
Date: Wed, 31 Aug 2022 17:14:45 +0000 (GMT)	[thread overview]
Message-ID: <20220831171445.A3FE93857C4C@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c3d4b6a6d9f382d7b88c2d25a1520acc1c3d51bd

commit c3d4b6a6d9f382d7b88c2d25a1520acc1c3d51bd
Author: Tom Tromey <tromey@adacore.com>
Date:   Thu Aug 11 11:59:06 2022 -0600

    Use scoped_restore in safe_parse_type
    
    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 = 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;
 }

                 reply	other threads:[~2022-08-31 17:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220831171445.A3FE93857C4C@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=gdb-cvs@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).