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: [PATCH v3 2/5] Get rid of "gdb_dirbuf" and use "getcwd (NULL, 0)"


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


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