]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR32093, -Walloc-size warning in ctf-hash.c
authorAlan Modra <amodra@gmail.com>
Thu, 29 Aug 2024 01:38:44 +0000 (11:08 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 29 Aug 2024 11:35:57 +0000 (21:05 +0930)
PR 32093
* ctf-hash.c (ctf_dynhash_create_sized, ctf_hashtab_insert): Avoid
-Walloc-size warning.

libctf/ctf-hash.c

index cd7473419cba12a8b6278c829b9e1ddfbc87e8d2..a451aa2e6ac6f9c55ece48ddc8a7091ce1dc086c 100644 (file)
@@ -164,7 +164,10 @@ ctf_dynhash_create_sized (unsigned long nelems, ctf_hash_fun hash_fun,
   if (key_free || value_free)
     dynhash = malloc (sizeof (ctf_dynhash_t));
   else
-    dynhash = malloc (offsetof (ctf_dynhash_t, key_free));
+    {
+      void *p = malloc (offsetof (ctf_dynhash_t, key_free));
+      dynhash = p;
+    }
   if (!dynhash)
     return NULL;
 
@@ -225,7 +228,10 @@ ctf_hashtab_insert (struct htab *htab, void *key, void *value,
       if (key_free || value_free)
        *slot = malloc (sizeof (ctf_helem_t));
       else
-       *slot = malloc (offsetof (ctf_helem_t, owner));
+       {
+         void *p = malloc (offsetof (ctf_helem_t, owner));
+         *slot = p;
+       }
       if (!*slot)
        return NULL;
       (*slot)->key = key;