summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-08-20 20:38:11 +0200
committerMichael S. Tsirkin <mst@redhat.com>2014-09-29 19:44:04 +0300
commit8ce3c44c925982d834a8200ee0c9c00a7e9db20e (patch)
treed222de64d89b7497571cf154bac482b0b12cef91
parented9114356b587b362f5ed10e75366a4f07ed32af (diff)
downloadfocaccia-qemu-8ce3c44c925982d834a8200ee0c9c00a7e9db20e.tar.gz
focaccia-qemu-8ce3c44c925982d834a8200ee0c9c00a7e9db20e.zip
loader: g_realloc(p, 0) frees and returns NULL, simplify
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>
-rw-r--r--include/hw/elf_ops.h15
1 files changed, 5 insertions, 10 deletions
diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h
index c6b5129bab..a517753a6f 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 */