[RFA,1/5] Darwin: fix bad loop incrementation

Message ID 1534932677-9496-2-git-send-email-roirand@adacore.com
State New, archived
Headers

Commit Message

Xavier Roirand Aug. 22, 2018, 10:11 a.m. UTC
  When reading symbols from the vector of oso files on Mac OS X
Darwin, a previous commit introduce a change in the loop and add
an increment at each loop iteration whereas this incrementation is
not needed since the increment or set of the loop control variable
is already done in the loop.

gdb/ChangeLog:

        * machoread.c (macho_symfile_read_all_oso): Remove uneeded
        incrementation.

Change-Id: I3a5a6deb4e9d834ee7d4217a62d90c2ffb7241bc
---
 gdb/machoread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Simon Marchi Aug. 22, 2018, 1:14 p.m. UTC | #1
On 2018-08-22 06:11, Xavier Roirand wrote:
> When reading symbols from the vector of oso files on Mac OS X
> Darwin, a previous commit introduce a change in the loop and add
> an increment at each loop iteration whereas this incrementation is
> not needed since the increment or set of the loop control variable
> is already done in the loop.
> 
> gdb/ChangeLog:
> 
>         * machoread.c (macho_symfile_read_all_oso): Remove uneeded
>         incrementation.
> 
> Change-Id: I3a5a6deb4e9d834ee7d4217a62d90c2ffb7241bc
> ---
>  gdb/machoread.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/machoread.c b/gdb/machoread.c
> index 0cbd209..3040fe7 100644
> --- a/gdb/machoread.c
> +++ b/gdb/machoread.c
> @@ -615,7 +615,7 @@ macho_symfile_read_all_oso (std::vector<oso_el>
> *oso_vector_ptr,
>    std::sort (oso_vector_ptr->begin (), oso_vector_ptr->end (),
>  	     oso_el_compare_name);
> 
> -  for (ix = 0; ix < oso_vector_ptr->size (); ++ix)
> +  for (ix = 0; ix < oso_vector_ptr->size ();)
>      {
>        int pfx_len;

I compared this with the original code (before 2cc9b3048b), that LGTM.

Simon
  
Simon Marchi Aug. 23, 2018, 3:21 p.m. UTC | #2
On 2018-08-22 09:14, Simon Marchi wrote:
> On 2018-08-22 06:11, Xavier Roirand wrote:
>> When reading symbols from the vector of oso files on Mac OS X
>> Darwin, a previous commit introduce a change in the loop and add
>> an increment at each loop iteration whereas this incrementation is
>> not needed since the increment or set of the loop control variable
>> is already done in the loop.
>> 
>> gdb/ChangeLog:
>> 
>>         * machoread.c (macho_symfile_read_all_oso): Remove uneeded
>>         incrementation.
>> 
>> Change-Id: I3a5a6deb4e9d834ee7d4217a62d90c2ffb7241bc
>> ---
>>  gdb/machoread.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/gdb/machoread.c b/gdb/machoread.c
>> index 0cbd209..3040fe7 100644
>> --- a/gdb/machoread.c
>> +++ b/gdb/machoread.c
>> @@ -615,7 +615,7 @@ macho_symfile_read_all_oso (std::vector<oso_el>
>> *oso_vector_ptr,
>>    std::sort (oso_vector_ptr->begin (), oso_vector_ptr->end (),
>>  	     oso_el_compare_name);
>> 
>> -  for (ix = 0; ix < oso_vector_ptr->size (); ++ix)
>> +  for (ix = 0; ix < oso_vector_ptr->size ();)
>>      {
>>        int pfx_len;
> 
> I compared this with the original code (before 2cc9b3048b), that LGTM.
> 
> Simon

I took the liberty of pushing this patch to master as well as 
gdb-8.2-branch, since it is a regression since 8.1.

Thanks,

Simon
  

Patch

diff --git a/gdb/machoread.c b/gdb/machoread.c
index 0cbd209..3040fe7 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -615,7 +615,7 @@  macho_symfile_read_all_oso (std::vector<oso_el> *oso_vector_ptr,
   std::sort (oso_vector_ptr->begin (), oso_vector_ptr->end (),
 	     oso_el_compare_name);
 
-  for (ix = 0; ix < oso_vector_ptr->size (); ++ix)
+  for (ix = 0; ix < oso_vector_ptr->size ();)
     {
       int pfx_len;