Use scoped_fd in more places
This changes a few more places to use scoped_fd. This allows the removal of some cleanups. Regression tested by the buildbot, though note that I'm not sure whether the buildbot actually builds anything using all of these files. gdb/ChangeLog 2018-03-08 Tom Tromey <tom@tromey.com> * source.c (get_filename_and_charpos): Use scoped_fd. * nto-procfs.c (procfs_open_1): Use scoped_fd. (procfs_pidlist): Likewise. * procfs.c (proc_get_LDT_entry): Use scoped_fd. (iterate_over_mappings): Likewise.
This commit is contained in:
parent
fdf07f3aeb
commit
5dc1a7047a
4 changed files with 37 additions and 46 deletions
12
gdb/source.c
12
gdb/source.c
|
@ -42,6 +42,7 @@
|
|||
#include "ui-out.h"
|
||||
#include "readline/readline.h"
|
||||
#include "common/enum-flags.h"
|
||||
#include "common/scoped_fd.h"
|
||||
#include <algorithm>
|
||||
#include "common/pathstuff.h"
|
||||
|
||||
|
@ -1215,24 +1216,21 @@ find_source_lines (struct symtab *s, int desc)
|
|||
static int
|
||||
get_filename_and_charpos (struct symtab *s, char **fullname)
|
||||
{
|
||||
int desc, linenums_changed = 0;
|
||||
struct cleanup *cleanups;
|
||||
int linenums_changed = 0;
|
||||
|
||||
desc = open_source_file (s);
|
||||
if (desc < 0)
|
||||
scoped_fd desc (open_source_file (s));
|
||||
if (desc.get () < 0)
|
||||
{
|
||||
if (fullname)
|
||||
*fullname = NULL;
|
||||
return 0;
|
||||
}
|
||||
cleanups = make_cleanup_close (desc);
|
||||
if (fullname)
|
||||
*fullname = s->fullname;
|
||||
if (s->line_charpos == 0)
|
||||
linenums_changed = 1;
|
||||
if (linenums_changed)
|
||||
find_source_lines (s, desc);
|
||||
do_cleanups (cleanups);
|
||||
find_source_lines (s, desc.get ());
|
||||
return linenums_changed;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue