]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libctf: dedup: comment fixes, debug indentation changes, and a tiny leak
authorNick Alcock <nick.alcock@oracle.com>
Fri, 25 Apr 2025 17:50:54 +0000 (18:50 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 25 Apr 2025 20:23:07 +0000 (21:23 +0100)
Getting these out of the way to avoid them wrecking the diffs for the next
commits.

libctf/ctf-dedup.c

index 456675252919523c5847c776baebf051b06d8fc9..d3ea5b039775633524e10a3f3663787be55e073d 100644 (file)
@@ -892,6 +892,7 @@ ctf_dedup_rhash_type (ctf_dict_t *fp, ctf_dict_t *input, ctf_dict_t **inputs,
          }
        if (ctf_errno (input) != ECTF_NEXT_END)
          {
+           ctf_next_destroy (i);
            whaterr = N_("error doing enum member iteration");
            goto input_err;
          }
@@ -1120,8 +1121,7 @@ ctf_dedup_hash_type (ctf_dict_t *fp, ctf_dict_t *input,
   /* We have never seen this type before, and must figure out its hash and the
      hashes of the types it cites.
 
-     Hash this type, and call ourselves recursively.  (The hashing part is
-     optional, and is disabled if overidden_hval is set.)  */
+     Hash this type, and call ourselves recursively.  */
 
   if ((hval = ctf_dedup_rhash_type (fp, input, inputs, input_num,
                                    type, type_id, tp, name, decorated,
@@ -1232,45 +1232,45 @@ ctf_dedup_populate_mappings (ctf_dict_t *fp, ctf_dict_t *input _libctf_unused_,
        }
     }
 #ifdef ENABLE_LIBCTF_HASH_DEBUGGING
-    {
-      /* Verify that all types with this hash are of the same kind, and that the
-        first TU a type was seen in never falls.  */
-
-      int err;
-      const void *one_id;
-      ctf_next_t *i = NULL;
-      int orig_kind = ctf_type_kind_unsliced (input, type);
-      int orig_first_tu;
-
-      orig_first_tu = CTF_DEDUP_GID_TO_INPUT
-       (ctf_dynhash_lookup (d->cd_output_first_gid, hval));
-      if (!ctf_assert (fp, orig_first_tu <= CTF_DEDUP_GID_TO_INPUT (id)))
-       return -1;
-
-      while ((err = ctf_dynset_cnext (type_ids, &i, &one_id)) == 0)
-       {
-         ctf_dict_t *foo = inputs[CTF_DEDUP_GID_TO_INPUT (one_id)];
-         ctf_id_t bar = CTF_DEDUP_GID_TO_TYPE (one_id);
-         if (ctf_type_kind_unsliced (foo, bar) != orig_kind)
-           {
-             ctf_err_warn (fp, 1, 0, "added wrong kind to output mapping "
-                           "for hash %s named %s: %p/%lx from %s is "
-                           "kind %i, but newly-added %p/%lx from %s is "
-                           "kind %i", hval,
-                           decorated_name ? decorated_name : "(unnamed)",
-                           (void *) foo, bar,
-                           ctf_link_input_name (foo),
-                           ctf_type_kind_unsliced (foo, bar),
-                           (void *) input, type,
-                           ctf_link_input_name (input), orig_kind);
-             if (!ctf_assert (fp, ctf_type_kind_unsliced (foo, bar)
-                              == orig_kind))
-               return -1;
-           }
-       }
-      if (err != ECTF_NEXT_END)
-       return ctf_set_errno (fp, err);
-    }
+  {
+    /* Verify that all types with this hash are of the same kind, and that the
+       first TU a type was seen in never falls.  */
+
+    int err;
+    const void *one_id;
+    ctf_next_t *i = NULL;
+    int orig_kind = ctf_type_kind_unsliced (input, type);
+    int orig_first_tu;
+
+    orig_first_tu = CTF_DEDUP_GID_TO_INPUT
+      (ctf_dynhash_lookup (d->cd_output_first_gid, hval));
+    if (!ctf_assert (fp, orig_first_tu <= CTF_DEDUP_GID_TO_INPUT (id)))
+      return -1;
+
+    while ((err = ctf_dynset_cnext (type_ids, &i, &one_id)) == 0)
+      {
+       ctf_dict_t *foo = inputs[CTF_DEDUP_GID_TO_INPUT (one_id)];
+       ctf_id_t bar = CTF_DEDUP_GID_TO_TYPE (one_id);
+       if (ctf_type_kind_unsliced (foo, bar) != orig_kind)
+         {
+           ctf_err_warn (fp, 1, 0, "added wrong kind to output mapping "
+                         "for hash %s named %s: %p/%lx from %s is "
+                         "kind %i, but newly-added %p/%lx from %s is "
+                         "kind %i", hval,
+                         decorated_name ? decorated_name : "(unnamed)",
+                         (void *) foo, bar,
+                         ctf_link_input_name (foo),
+                         ctf_type_kind_unsliced (foo, bar),
+                         (void *) input, type,
+                         ctf_link_input_name (input), orig_kind);
+           if (!ctf_assert (fp, ctf_type_kind_unsliced (foo, bar)
+                            == orig_kind))
+             return -1;
+         }
+      }
+    if (err != ECTF_NEXT_END)
+      return ctf_set_errno (fp, err);
+  }
 #endif
 
   /* This function will be repeatedly called for the same types many times: