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

Tested on aarch64-linux.

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

index fd8e27735f086c1ea73b56b47da4b4db05ac88b6..8879d13c97479cf1a69692a71e10428b97d357f7 100644 (file)
@@ -1118,19 +1118,14 @@ pipe_command (const char *arg, int from_tty)
   if (to_shell_command == nullptr)
     error (_("Error launching \"%s\""), shell_command);
 
-  try
-    {
-      stdio_file pipe_file (to_shell_command);
+  int exit_status;
+  {
+    SCOPE_EXIT { exit_status = pclose (to_shell_command); };
 
-      execute_command_to_ui_file (&pipe_file, gdb_cmd.c_str (), from_tty);
-    }
-  catch (...)
-    {
-      pclose (to_shell_command);
-      throw;
-    }
+    stdio_file pipe_file (to_shell_command);
 
-  int exit_status = pclose (to_shell_command);
+    execute_command_to_ui_file (&pipe_file, gdb_cmd.c_str (), from_tty);
+  }
 
   if (exit_status < 0)
     error (_("shell command \"%s\" failed: %s"), shell_command,