diff options
author | Tom Tromey <tom@tromey.com> | 2017-11-22 23:37:38 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-03-07 15:36:28 -0700 |
commit | e0d3522b888033febd153a4a7d3b7c5c13641f09 (patch) | |
tree | 9c5c11152ba3b7202fac5dba1a9f21a35c85d3d5 /gdb/remote.c | |
parent | d6ab64818b9d212691c200c292dc0f18d193598c (diff) | |
download | gdb-e0d3522b888033febd153a4a7d3b7c5c13641f09.zip gdb-e0d3522b888033febd153a4a7d3b7c5c13641f09.tar.gz gdb-e0d3522b888033febd153a4a7d3b7c5c13641f09.tar.bz2 |
Return gdb::optional<std::string> from target_fileio_readlink
This changes to_fileio_readlink and target_fileio_readlink to return a
gdb::optional<std::sring>, and then fixes up the callers and
implementations. This allows the removal of some cleanups.
Regression tested by the buildbot.
gdb/ChangeLog
2018-03-07 Tom Tromey <tom@tromey.com>
* linux-tdep.c (linux_info_proc): Update.
* target.h (struct target_ops) <to_fileio_readlink>: Return
optional<string>.
(target_fileio_readlink): Return optional<string>.
* remote.c (remote_hostio_readlink): Return optional<string>.
* inf-child.c (inf_child_fileio_readlink): Return
optional<string>.
* target.c (target_fileio_readlink): Return optional<string>.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r-- | gdb/remote.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/gdb/remote.c b/gdb/remote.c index 15d6c5b..134a97e 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -11713,7 +11713,7 @@ remote_hostio_unlink (struct target_ops *self, /* Implementation of to_fileio_readlink. */ -static char * +static gdb::optional<std::string> remote_hostio_readlink (struct target_ops *self, struct inferior *inf, const char *filename, int *remote_errno) @@ -11724,10 +11724,9 @@ remote_hostio_readlink (struct target_ops *self, int left = get_remote_packet_size (); int len, attachment_len; int read_len; - char *ret; if (remote_hostio_set_filesystem (inf, remote_errno) != 0) - return NULL; + return {}; remote_buffer_add_string (&p, &left, "vFile:readlink:"); @@ -11739,16 +11738,15 @@ remote_hostio_readlink (struct target_ops *self, &attachment_len); if (len < 0) - return NULL; + return {}; - ret = (char *) xmalloc (len + 1); + std::string ret (len, '\0'); read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len, - (gdb_byte *) ret, len); + (gdb_byte *) &ret[0], len); if (read_len != len) error (_("Readlink returned %d, but %d bytes."), len, read_len); - ret[len] = '\0'; return ret; } |