loader: g_realloc(p, 0) frees and returns NULL, simplify
PATCH 1/1 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.
--- include/hw/elf_ops.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
include/hw/elf_ops.h +5 -10
@@ -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 */
Signature · 1 line
1.9.3
Quoted 11 lines · Markus Armbruster
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 <[email protected]>--- include/hw/elf_ops.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 8 lines · Markus Armbruster
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 <[email protected]>
Quoted 34 lines
--- include/hw/elf_ops.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)include/hw/elf_ops.h +5
-10@@ -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 */ Signature · 1 line
1.9.3
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Markus Armbruster
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 <[email protected]>
Michael, can you take this through your tree?
Ping?
Quoted 15 lines · Markus Armbruster
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Markus Armbruster
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 <[email protected]>Michael, can you take this through your tree?