This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v3 2/5] Get rid of "gdb_dirbuf" and use "getcwd (NULL, 0)"
- From: Pedro Alves <palves at redhat dot com>
- To: Sergio Durigan Junior <sergiodj at redhat dot com>, GDB Patches <gdb-patches at sourceware dot org>
- Date: Fri, 22 Sep 2017 12:19:00 +0100
- Subject: Re: [PATCH v3 2/5] Get rid of "gdb_dirbuf" and use "getcwd (NULL, 0)"
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5613F267C8
- References: <20170912042325.14927-1-sergiodj@redhat.com> <20170921225926.23132-1-sergiodj@redhat.com> <20170921225926.23132-3-sergiodj@redhat.com>
On 09/21/2017 11:59 PM, Sergio Durigan Junior wrote:
>
> gdb/ChangeLog:
> yyyy-mm-dd Sergio Durigan Junior <sergiodj@redhat.com>
>
> * cli/cli-cmds.c (pwd_command): Use "getcwd (NULL, 0)".
> (cd_command): Likewise. Free "current_directory" before
> assigning to it.
> * main.c (captured_main_1): Use "getcwd (NULL, 0)".
> * mi/mi-cmd-env.c (mi_cmd_env_pwd): Likewise.
> * top.c (gdb_dirbuf): Remove global declaration.
> * top.h (gdb_dirbuf): Likewise.
OK. And trying the new thing:
Reviewed-by: Pedro Alves <palves@redhat.com>
... provided the nit below is addressed.
You can push patches 1 and 2 now, without waiting for the
rest of the series.
> diff --git a/gdb/mi/mi-cmd-env.c b/gdb/mi/mi-cmd-env.c
> index 977b6e274d..db87ead33d 100644
> --- a/gdb/mi/mi-cmd-env.c
> +++ b/gdb/mi/mi-cmd-env.c
> @@ -73,12 +73,12 @@ mi_cmd_env_pwd (const char *command, char **argv, int argc)
> }
>
> /* Otherwise the mi level is 2 or higher. */
> -
> - if (! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)))
Please leave the empty line after the comment. That comment is
logically related to the code above, not the getcwd call.
> + gdb::unique_xmalloc_ptr<char> cwd (getcwd (NULL, 0));
> + if (cwd == NULL)
> error (_("-environment-pwd: error finding name of working directory: %s"),
> safe_strerror (errno));
> -
> - uiout->field_string ("cwd", gdb_dirbuf);
> +
> + uiout->field_string ("cwd", cwd.get ());
> }
Thanks,
Pedro Alves