From: Tom de Vries Date: Tue, 24 Sep 2024 11:50:19 +0000 (+0200) Subject: [gdb] Eliminate catch(...) in execute_fn_to_string X-Git-Tag: gdb-16-branchpoint~830 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7fd46e6b2ac5a30ecb33b4b290d824247cb68a20;p=thirdparty%2Fbinutils-gdb.git [gdb] Eliminate catch(...) in execute_fn_to_string Remove duplicate code in execute_fn_to_string using SCOPE_EXIT. Tested on aarch64-linux. Approved-By: Tom Tromey --- diff --git a/gdb/top.c b/gdb/top.c index d6bf1d448d5..eae54aae1ff 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -632,19 +632,9 @@ execute_fn_to_string (std::string &res, std::function 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. */