]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb] Eliminate catch(...) in execute_fn_to_string
authorTom de Vries <tdevries@suse.de>
Tue, 24 Sep 2024 11:50:19 +0000 (13:50 +0200)
committerTom de Vries <tdevries@suse.de>
Tue, 24 Sep 2024 11:50:19 +0000 (13:50 +0200)
Remove duplicate code in execute_fn_to_string using SCOPE_EXIT.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/top.c

index d6bf1d448d5b39084caa7535c78e0f1729e689d1..eae54aae1ffbe65b34436baca0b8125a4473f6a8 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -632,19 +632,9 @@ execute_fn_to_string (std::string &res, std::function<void(void)> fn,
 {
   string_file str_file (term_out);
 
-  try
-    {
-      execute_fn_to_ui_file (&str_file, fn);
-    }
-  catch (...)
-    {
-      /* Finally.  */
-      res = str_file.release ();
-      throw;
-    }
+  SCOPE_EXIT { res = str_file.release (); };
 
-  /* And finally.  */
-  res = str_file.release ();
+  execute_fn_to_ui_file (&str_file, fn);
 }
 
 /* See top.h.  */