qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	Peter Maydell <peter.maydell@linaro.org>,
	Markus Armbruster <armbru@redhat.com>,
	Anthony Liguori <aliguori@amazon.com>,
	Alexander Graf <agraf@suse.de>
Subject: [Qemu-devel] [PULL 1/5] loader: g_realloc(p, 0) frees and returns NULL, simplify
Date: Tue, 30 Sep 2014 12:40:01 +0300	[thread overview]
Message-ID: <1412069893-4717-2-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1412069893-4717-1-git-send-email-mst@redhat.com>

From: Markus Armbruster <armbru@redhat.com>

Once upon a time, it was decided that qemu_realloc(ptr, 0) should
abort.  Switching to glib retired that bright idea.  A bit of code
that was added to cope with it (commit 3e372cf) is still around.  Bury
it.

See also commit 6528499.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/hw/elf_ops.h | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h
index c6b5129..a517753 100644
--- a/include/hw/elf_ops.h
+++ b/include/hw/elf_ops.h
@@ -147,18 +147,13 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
         }
         i++;
     }
-    if (nsyms) {
-        syms = g_realloc(syms, nsyms * sizeof(*syms));
+    syms = g_realloc(syms, nsyms * sizeof(*syms));
 
-        qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
-        for (i = 0; i < nsyms - 1; i++) {
-            if (syms[i].st_size == 0) {
-                syms[i].st_size = syms[i + 1].st_value - syms[i].st_value;
-            }
+    qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
+    for (i = 0; i < nsyms - 1; i++) {
+        if (syms[i].st_size == 0) {
+            syms[i].st_size = syms[i + 1].st_value - syms[i].st_value;
         }
-    } else {
-        g_free(syms);
-        syms = NULL;
     }
 
     /* String table */
-- 
MST

  reply	other threads:[~2014-09-30  9:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-30  9:39 [Qemu-devel] [PULL 0/5] pci, pc, virtio, misc bugfixes Michael S. Tsirkin
2014-09-30  9:40 ` Michael S. Tsirkin [this message]
2014-09-30  9:40 ` [Qemu-devel] [PULL 2/5] Revert "virtio-pci: fix migration for pci bus master" Michael S. Tsirkin
2014-09-30  9:40 ` [Qemu-devel] [PULL 3/5] pci-hotplug-old: avoid losing error message Michael S. Tsirkin
2014-09-30  9:40 ` [Qemu-devel] [PULL 4/5] pc-dimm: Don't check dimm->node when there is non-NUMA config Michael S. Tsirkin
2014-09-30  9:40 ` [Qemu-devel] [PULL 5/5] vl: Adjust the place of calling mlockall to speedup VM's startup Michael S. Tsirkin
2014-09-30 13:59 ` [Qemu-devel] [PULL 0/5] pci, pc, virtio, misc bugfixes Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1412069893-4717-2-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=aliguori@amazon.com \
    --cc=armbru@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).