]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
get_type_abbrev_from_form tidy
authorAlan Modra <amodra@gmail.com>
Wed, 28 Aug 2024 12:07:13 +0000 (21:37 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 29 Aug 2024 11:35:57 +0000 (21:05 +0930)
* dwarf.c (get_type_abbrev_from_form): Make uvalue param a
uint64_t.  Localise variables.  Don't bother clearing *data_return
and *addrev_num_return for a NULL return value.

binutils/dwarf.c

index 13a91624200eaeb2c379fc53864da5a570316cac..424353ccdb226b2b8d79db7489cca77269a53804 100644 (file)
@@ -2035,7 +2035,7 @@ skip_attr_bytes (unsigned long form,
 
 static abbrev_entry *
 get_type_abbrev_from_form (unsigned long form,
-                          unsigned long uvalue,
+                          uint64_t uvalue,
                           uint64_t cu_offset,
                           unsigned char *cu_end,
                           const struct dwarf_section *section,
@@ -2043,16 +2043,6 @@ get_type_abbrev_from_form (unsigned long form,
                           unsigned char **data_return,
                           abbrev_map **map_return)
 {
-  unsigned long   abbrev_number;
-  abbrev_map *    map;
-  abbrev_entry *  entry;
-  unsigned char * data;
-
-  if (abbrev_num_return != NULL)
-    * abbrev_num_return = 0;
-  if (data_return != NULL)
-    * data_return = NULL;
-
   switch (form)
     {
     case DW_FORM_GNU_ref_alt:
@@ -2063,8 +2053,8 @@ get_type_abbrev_from_form (unsigned long form,
     case DW_FORM_ref_addr:
       if (uvalue >= section->size)
        {
-         warn (_("Unable to resolve ref_addr form: uvalue %lx "
-                 "> section size %" PRIx64 " (%s)\n"),
+         warn (_("Unable to resolve ref_addr form: uvalue %" PRIx64
+                 " >= section size %" PRIx64 " (%s)\n"),
                uvalue, section->size, section->name);
          return NULL;
        }
@@ -2082,8 +2072,8 @@ get_type_abbrev_from_form (unsigned long form,
       if (uvalue + cu_offset < uvalue
          || uvalue + cu_offset > (size_t) (cu_end - section->start))
        {
-         warn (_("Unable to resolve ref form: uvalue %lx + cu_offset %" PRIx64
-                 " > CU size %tx\n"),
+         warn (_("Unable to resolve ref form: uvalue %" PRIx64
+                 " + cu_offset %" PRIx64 " > CU size %tx\n"),
                uvalue, cu_offset, cu_end - section->start);
          return NULL;
        }
@@ -2097,17 +2087,18 @@ get_type_abbrev_from_form (unsigned long form,
       return NULL;
     }
 
-  data = (unsigned char *) section->start + uvalue;
-  map = find_abbrev_map_by_offset (uvalue);
+  abbrev_map *map = find_abbrev_map_by_offset (uvalue);
 
   if (map == NULL)
     {
-      warn (_("Unable to find abbreviations for CU offset %#lx\n"), uvalue);
+      warn (_("Unable to find abbreviations for CU offset %" PRIx64 "\n"),
+           uvalue);
       return NULL;
     }
   if (map->list == NULL)
     {
-      warn (_("Empty abbreviation list encountered for CU offset %lx\n"), uvalue);
+      warn (_("Empty abbreviation list encountered for CU offset %" PRIx64 "\n"),
+           uvalue);
       return NULL;
     }
 
@@ -2119,20 +2110,23 @@ get_type_abbrev_from_form (unsigned long form,
        *map_return = NULL;
     }
 
+  unsigned char *data = section->start + uvalue;
   if (form == DW_FORM_ref_addr)
     cu_end = section->start + map->end;
 
+  unsigned long abbrev_number;
   READ_ULEB (abbrev_number, data, cu_end);
 
-  for (entry = map->list->first_abbrev; entry != NULL; entry = entry->next)
-    if (entry->number == abbrev_number)
-      break;
-
   if (abbrev_num_return != NULL)
-    * abbrev_num_return = abbrev_number;
+    *abbrev_num_return = abbrev_number;
 
   if (data_return != NULL)
-    * data_return = data;
+    *data_return = data;
+
+  abbrev_entry *entry;
+  for (entry = map->list->first_abbrev; entry != NULL; entry = entry->next)
+    if (entry->number == abbrev_number)
+      break;
 
   if (entry == NULL)
     warn (_("Unable to find entry for abbreviation %lu\n"), abbrev_number);