From d419f42dd3f3635fc036413258ed530676998191 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 26 Apr 2017 21:39:46 -0600 Subject: Introduce and use gdb_file_up This introduces gdb_file_up, a unique pointer holding a FILE*, and then changes some code in gdb to use it. In particular gdb_fopen_cloexec now returns a gdb_file_up. This allow removing some cleanups. ChangeLog 2017-08-03 Tom Tromey * xml-support.c (xml_fetch_content_from_file): Update. * ui-file.c (stdio_file::open): Update. * tracefile-tfile.c (tfile_start): Update. * remote.c (remote_file_put, remote_file_get): Update. * nat/linux-procfs.c (linux_proc_get_int) (linux_proc_pid_get_state, linux_proc_tid_get_name): Update. * nat/linux-osdata.c (linux_common_core_of_thread): Update. (command_from_pid, commandline_from_pid, linux_xfer_osdata_cpus) (print_sockets, linux_xfer_osdata_shm, linux_xfer_osdata_sem) (linux_xfer_osdata_msg, linux_xfer_osdata_modules): Update. * nat/linux-btrace.c (linux_determine_kernel_start): Update. * linux-nat.c (linux_proc_pending_signals): Update. * dwarf2read.c (write_psymtabs_to_index): Use gdb_file_up. (file_closer): Remove. * compile/compile.c (compile_to_object): Update. * common/filestuff.h (struct gdb_file_deleter): New. (gdb_file_up): New typedef. (gdb_fopen_cloexec): Change return type. * common/filestuff.c (gdb_fopen_cloexec): Return gdb_file_up. * cli/cli-dump.c (fopen_with_cleanup): Remove. (dump_binary_file, restore_binary_file): Update. * auto-load.c (auto_load_objfile_script_1): Update. --- gdb/ui-file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gdb/ui-file.c') diff --git a/gdb/ui-file.c b/gdb/ui-file.c index 60e32746eb0..046e14fc8ed 100644 --- a/gdb/ui-file.c +++ b/gdb/ui-file.c @@ -177,12 +177,12 @@ stdio_file::open (const char *name, const char *mode) m_close_p = false; } - FILE *f = gdb_fopen_cloexec (name, mode); + gdb_file_up f = gdb_fopen_cloexec (name, mode); if (f == NULL) return false; - set_stream (f); + set_stream (f.release ()); m_close_p = true; return true; -- cgit v1.2.1