This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA 6/6] Return unique_xmalloc_ptr from target_fileio_read_stralloc


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]