diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-07-22 11:56:33 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-09-30 15:21:48 -0400 |
commit | 13084383e8955c2ff7017ac8839301688a9ee34d (patch) | |
tree | ffc4d5429e7315de53715fe7fce7bd26abd958b8 /gdb/solib.c | |
parent | e6e51c9c4b402cd46595790b26087ebf2fead8c1 (diff) | |
download | gdb-13084383e8955c2ff7017ac8839301688a9ee34d.zip gdb-13084383e8955c2ff7017ac8839301688a9ee34d.tar.gz gdb-13084383e8955c2ff7017ac8839301688a9ee34d.tar.bz2 |
gdbsupport: make gdb_open_cloexec return scoped_fd
Make gdb_open_cloexec return a scoped_fd, to encourage using automatic
management of the file descriptor closing. Except in the most trivial
cases, I changed the callers to just release the fd, which retains their
existing behavior. That will allow the transition to using scoped_fd
more to go gradually, one caller at a time.
Change-Id: Ife022b403f96e71d5ebb4f1056ef6251b30fe554
Diffstat (limited to 'gdb/solib.c')
-rw-r--r-- | gdb/solib.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/gdb/solib.c b/gdb/solib.c index e30affb..dba3d84 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -257,7 +257,8 @@ solib_find_1 (const char *in_pathname, int *fd, bool is_solib) } /* Now see if we can open it. */ - found_file = gdb_open_cloexec (temp_pathname.get (), O_RDONLY | O_BINARY, 0); + found_file = gdb_open_cloexec (temp_pathname.get (), + O_RDONLY | O_BINARY, 0).release (); /* If the search in gdb_sysroot failed, and the path name has a drive spec (e.g, c:/foo), try stripping ':' from the drive spec, @@ -278,7 +279,7 @@ solib_find_1 (const char *in_pathname, int *fd, bool is_solib) in_pathname + 2, (char *) NULL)); found_file = gdb_open_cloexec (temp_pathname.get (), - O_RDONLY | O_BINARY, 0); + O_RDONLY | O_BINARY, 0).release (); if (found_file < 0) { /* If the search in gdb_sysroot still failed, try fully @@ -292,7 +293,7 @@ solib_find_1 (const char *in_pathname, int *fd, bool is_solib) in_pathname + 2, (char *) NULL)); found_file = gdb_open_cloexec (temp_pathname.get (), - O_RDONLY | O_BINARY, 0); + O_RDONLY | O_BINARY, 0).release (); } } |