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 Friday, September 22 2017, Pedro Alves wrote:

> 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.

AFAIU I had to add this to the commit log.  I did this; if this wasn't
correct, I apologize.

>> 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.

Done.

>> +  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

Pushed.

43573013c9836f2b91b74b9b29dac35fdb41e06b

Thanks,

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/


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