This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 6/6] Return unique_xmalloc_ptr from target_fileio_read_stralloc
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: Tom Tromey <tom at tromey dot com>, <gdb-patches at sourceware dot org>
- Date: Mon, 16 Oct 2017 17:07:27 -0400
- Subject: Re: [RFA 6/6] Return unique_xmalloc_ptr from target_fileio_read_stralloc
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=simon dot marchi at ericsson dot com;
- References: <20171016030427.21349-1-tom@tromey.com> <20171016030427.21349-7-tom@tromey.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
On 2017-10-15 11:04 PM, Tom Tromey wrote:
> Change target_fileio_read_stralloc to return unique_xmalloc_ptr and
> fix up the callers. This removes a number of cleanups.
>
> ChangeLog
> 2017-10-15 Tom Tromey <tom@tromey.com>
>
> * linux-tdep.c (linux_info_proc, linux_find_memory_regions_full)
> (linux_fill_prpsinfo, linux_vsyscall_range_raw): Update.
> * target.c (target_fileio_read_stralloc): Update.
> * sparc64-tdep.c (adi_is_addr_mapped): Update.
> * target.h (target_fileio_read_stralloc): Return
> unique_xmalloc_ptr.
> ---
> gdb/ChangeLog | 9 +++++
> gdb/linux-tdep.c | 117 +++++++++++++++++++++--------------------------------
> gdb/sparc64-tdep.c | 12 ++----
> gdb/target.c | 8 ++--
> gdb/target.h | 4 +-
> 5 files changed, 64 insertions(+), 86 deletions(-)
>
> diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
> index 8751718e84..d890083fa2 100644
> --- a/gdb/linux-tdep.c
> +++ b/gdb/linux-tdep.c
> @@ -749,13 +749,10 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
> if (cmdline_f)
> {
> xsnprintf (filename, sizeof filename, "/proc/%ld/cmdline", pid);
> - data = target_fileio_read_stralloc (NULL, filename);
> - if (data)
> - {
> - struct cleanup *cleanup = make_cleanup (xfree, data);
> - printf_filtered ("cmdline = '%s'\n", data);
> - do_cleanups (cleanup);
> - }
> + gdb::unique_xmalloc_ptr<char> cmdline
> + = target_fileio_read_stralloc (NULL, filename);
> + if (cmdline)
> + printf_filtered ("cmdline = '%s'\n", cmdline.get ());
> else
> warning (_("unable to open /proc file '%s'"), filename);
> }
> @@ -788,10 +785,10 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
> if (mappings_f)
> {
> xsnprintf (filename, sizeof filename, "/proc/%ld/maps", pid);
> - data = target_fileio_read_stralloc (NULL, filename);
> - if (data)
> + gdb::unique_xmalloc_ptr<char> map
> + = target_fileio_read_stralloc (NULL, filename);
> + if (map)
if (map != NULL)
Otherwise, LGTM.
Simon