public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] _bfd_xcoff_read_ar_hdr tidy
@ 2020-03-10 15:25 gdb-buildbot
  2020-03-10 15:25 ` Failures on Fedora-x86_64-cc-with-index, branch master gdb-buildbot
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gdb-buildbot @ 2020-03-10 15:25 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT 05f52dc2e1359fc4f69fab5c39fdfdf5efe93a15 ***

commit 05f52dc2e1359fc4f69fab5c39fdfdf5efe93a15
Author:     Alan Modra <amodra@gmail.com>
AuthorDate: Thu Feb 27 14:11:35 2020 +1030
Commit:     Alan Modra <amodra@gmail.com>
CommitDate: Thu Feb 27 17:05:08 2020 +1030

    _bfd_xcoff_read_ar_hdr tidy
    
            * coff-rs6000.c (_bfd_xcoff_read_ar_hdr): Put all data in one
            malloc'd block.

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ff03baa0dc..e5cf5e125e 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2020-02-27  Alan Modra  <amodra@gmail.com>
+
+	* coff-rs6000.c (_bfd_xcoff_read_ar_hdr): Put all data in one
+	malloc'd block.
+
 2020-02-27  Alan Modra  <amodra@gmail.com>
 
 	* bfd.c (bfd_stat_arch_elt): Use vector of containing archive,
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 8b8f472504..1cc708ce1b 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -1491,32 +1491,23 @@ _bfd_xcoff_read_ar_hdr (bfd *abfd)
 {
   bfd_size_type namlen;
   struct areltdata *ret;
-  bfd_size_type amt = sizeof (struct areltdata);
-
-  ret = (struct areltdata *) bfd_zmalloc (amt);
-  if (ret == NULL)
-    return NULL;
+  bfd_size_type amt;
 
   if (! xcoff_big_format_p (abfd))
     {
       struct xcoff_ar_hdr hdr;
       struct xcoff_ar_hdr *hdrp;
 
-      if (bfd_bread (&hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
-	  != SIZEOF_AR_HDR)
-	{
-	  free (ret);
-	  return NULL;
-	}
+      if (bfd_bread (&hdr, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR)
+	return NULL;
 
       GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
-      amt = SIZEOF_AR_HDR + namlen + 1;
-      hdrp = (struct xcoff_ar_hdr *) bfd_alloc (abfd, amt);
-      if (hdrp == NULL)
-	{
-	  free (ret);
-	  return NULL;
-	}
+      amt = sizeof (struct areltdata) + SIZEOF_AR_HDR + namlen + 1;
+      ret = (struct areltdata *) bfd_malloc (amt);
+      if (ret == NULL)
+	return ret;
+
+      hdrp = (struct xcoff_ar_hdr *) (ret + 1);
       memcpy (hdrp, &hdr, SIZEOF_AR_HDR);
       if (bfd_bread ((char *) hdrp + SIZEOF_AR_HDR, namlen, abfd) != namlen)
 	{
@@ -1534,21 +1525,16 @@ _bfd_xcoff_read_ar_hdr (bfd *abfd)
       struct xcoff_ar_hdr_big hdr;
       struct xcoff_ar_hdr_big *hdrp;
 
-      if (bfd_bread (&hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
-	  != SIZEOF_AR_HDR_BIG)
-	{
-	  free (ret);
-	  return NULL;
-	}
+      if (bfd_bread (&hdr, SIZEOF_AR_HDR_BIG, abfd) != SIZEOF_AR_HDR_BIG)
+	return NULL;
 
       GET_VALUE_IN_FIELD (namlen, hdr.namlen, 10);
-      amt = SIZEOF_AR_HDR_BIG + namlen + 1;
-      hdrp = (struct xcoff_ar_hdr_big *) bfd_alloc (abfd, amt);
-      if (hdrp == NULL)
-	{
-	  free (ret);
-	  return NULL;
-	}
+      amt = sizeof (struct areltdata) + SIZEOF_AR_HDR_BIG + namlen + 1;
+      ret = (struct areltdata *) bfd_malloc (amt);
+      if (ret == NULL)
+	return ret;
+
+      hdrp = (struct xcoff_ar_hdr_big *) (ret + 1);
       memcpy (hdrp, &hdr, SIZEOF_AR_HDR_BIG);
       if (bfd_bread ((char *) hdrp + SIZEOF_AR_HDR_BIG, namlen, abfd) != namlen)
 	{


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-03-12  5:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-10 15:25 [binutils-gdb] _bfd_xcoff_read_ar_hdr tidy gdb-buildbot
2020-03-10 15:25 ` Failures on Fedora-x86_64-cc-with-index, branch master gdb-buildbot
2020-03-10 15:32 ` Failures on Fedora-i686, " gdb-buildbot
2020-03-10 15:56 ` Failures on Fedora-x86_64-m32, " gdb-buildbot
2020-03-10 16:14 ` Failures on Fedora-x86_64-m64, " gdb-buildbot
2020-03-10 16:37 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot
2020-03-10 17:09 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot
2020-03-11 16:48 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot
2020-03-12  5:45 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).