[PATCH 1/3] Refactor get_init_files to use std::string

Sergio Durigan Junior sergiodj@redhat.com
Wed Aug 21 17:34:00 GMT 2019


On Wednesday, August 21 2019, Christian Biesinger wrote:

>> > -       char *relocated_sysgdbinit;
>> > +       std::string relocated_sysgdbinit;
>> >
>> >         /* If SYSTEM_GDBINIT lives in data-directory, and data-directory
>> >            has been provided, search for SYSTEM_GDBINIT there.  */
>> > @@ -226,28 +225,30 @@ get_init_files (const char **system_gdbinit,
>> >           {
>> >             /* Append the part of SYSTEM_GDBINIT that follows GDB_DATADIR
>> >                to gdb_datadir.  */
>> > -           char *tmp_sys_gdbinit = xstrdup (&SYSTEM_GDBINIT[datadir_len]);
>> > -           char *p;
>> >
>> > -           for (p = tmp_sys_gdbinit; IS_DIR_SEPARATOR (*p); ++p)
>> > +           size_t start = datadir_len;
>> > +           for (; IS_DIR_SEPARATOR (SYSTEM_GDBINIT[start]); ++start)
>> >               continue;
>>
>> This seems wrong; you're starting the iteration from
>> 'SYSTEM_GDBINIT[start]', but 'start' is 'datadir_len'.
>
> The previous version first initialized tmp_sys_gdbinit to start from
> &SYSTEM_GDBINIT[datadir_len], so I think my change is correct (and
> simpler)?

Ah, right, now I see the '&SYSTEM_GDBINIT[datadir_len]' there.  That
looks fine, then.

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/



More information about the Gdb-patches mailing list