[2/3] Minor cleanup to ada_identical_enum_types_p

Message ID 20240906-ada-enum-stuff-v1-2-9d0fb5ac86bd@adacore.com
State New
Headers
Series Minor fixes to ada_identical_enum_types_p |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom Tromey Sept. 6, 2024, 3:54 p.m. UTC
  This moves the declaration of 'i' into the 'for' loops in
ada_identical_enum_types_p.  This is just a trivial cleanup.
---
 gdb/ada-lang.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
  

Comments

Tom de Vries Sept. 7, 2024, 2:09 a.m. UTC | #1
On 9/6/24 17:54, Tom Tromey wrote:
> This moves the declaration of 'i' into the 'for' loops in
> ada_identical_enum_types_p.  This is just a trivial cleanup.

LGTM.

Approved-By: Tom de Vries <tdevries@suse.de>

Thanks,
- Tom

> ---
>   gdb/ada-lang.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
> index 9710ca5f224..7be5dbb62de 100644
> --- a/gdb/ada-lang.c
> +++ b/gdb/ada-lang.c
> @@ -4976,21 +4976,19 @@ is_nondebugging_type (struct type *type)
>   static bool
>   ada_identical_enum_types_p (struct type *type1, struct type *type2)
>   {
> -  int i;
> -
>     /* The heuristic we use here is fairly conservative.  We consider
>        that 2 enumerate types are identical if they have the same
>        number of enumerals and that all enumerals have the same
>        underlying value and name.  */
>   
>     /* All enums in the type should have an identical underlying value.  */
> -  for (i = 0; i < type1->num_fields (); i++)
> +  for (int i = 0; i < type1->num_fields (); i++)
>       if (type1->field (i).loc_enumval () != type2->field (i).loc_enumval ())
>         return false;
>   
>     /* All enumerals should also have the same name (modulo any numerical
>        suffix).  */
> -  for (i = 0; i < type1->num_fields (); i++)
> +  for (int i = 0; i < type1->num_fields (); i++)
>       {
>         const char *name_1 = type1->field (i).name ();
>         const char *name_2 = type2->field (i).name ();
>
  

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 9710ca5f224..7be5dbb62de 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4976,21 +4976,19 @@  is_nondebugging_type (struct type *type)
 static bool
 ada_identical_enum_types_p (struct type *type1, struct type *type2)
 {
-  int i;
-
   /* The heuristic we use here is fairly conservative.  We consider
      that 2 enumerate types are identical if they have the same
      number of enumerals and that all enumerals have the same
      underlying value and name.  */
 
   /* All enums in the type should have an identical underlying value.  */
-  for (i = 0; i < type1->num_fields (); i++)
+  for (int i = 0; i < type1->num_fields (); i++)
     if (type1->field (i).loc_enumval () != type2->field (i).loc_enumval ())
       return false;
 
   /* All enumerals should also have the same name (modulo any numerical
      suffix).  */
-  for (i = 0; i < type1->num_fields (); i++)
+  for (int i = 0; i < type1->num_fields (); i++)
     {
       const char *name_1 = type1->field (i).name ();
       const char *name_2 = type2->field (i).name ();