* [Qemu-devel] [PATCH 1/1] loader: g_realloc(p, 0) frees and returns NULL, simplify
@ 2014-08-20 18:38 Markus Armbruster
2014-08-20 18:49 ` Eric Blake
2014-08-20 21:22 ` Michael S. Tsirkin
0 siblings, 2 replies; 5+ messages in thread
From: Markus Armbruster @ 2014-08-20 18:38 UTC (permalink / raw)
To: qemu-devel; +Cc: aurelien, mst
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>
---
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 */
--
1.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 1/1] loader: g_realloc(p, 0) frees and returns NULL, simplify
2014-08-20 18:38 [Qemu-devel] [PATCH 1/1] loader: g_realloc(p, 0) frees and returns NULL, simplify Markus Armbruster
@ 2014-08-20 18:49 ` Eric Blake
2014-08-20 21:22 ` Michael S. Tsirkin
1 sibling, 0 replies; 5+ messages in thread
From: Eric Blake @ 2014-08-20 18:49 UTC (permalink / raw)
To: Markus Armbruster, qemu-devel; +Cc: aurelien, mst
[-- Attachment #1: Type: text/plain, Size: 626 bytes --]
On 08/20/2014 12:38 PM, Markus Armbruster wrote:
> 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>
> ---
> include/hw/elf_ops.h | 15 +++++----------
> 1 file changed, 5 insertions(+), 10 deletions(-)
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 1/1] loader: g_realloc(p, 0) frees and returns NULL, simplify
2014-08-20 18:38 [Qemu-devel] [PATCH 1/1] loader: g_realloc(p, 0) frees and returns NULL, simplify Markus Armbruster
2014-08-20 18:49 ` Eric Blake
@ 2014-08-20 21:22 ` Michael S. Tsirkin
2014-09-08 16:54 ` Markus Armbruster
1 sibling, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2014-08-20 21:22 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel, aurelien
On Wed, Aug 20, 2014 at 08:38:11PM +0200, Markus Armbruster wrote:
> 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>
Acked-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 */
> --
> 1.9.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 1/1] loader: g_realloc(p, 0) frees and returns NULL, simplify
2014-08-20 21:22 ` Michael S. Tsirkin
@ 2014-09-08 16:54 ` Markus Armbruster
2014-09-17 7:35 ` Markus Armbruster
0 siblings, 1 reply; 5+ messages in thread
From: Markus Armbruster @ 2014-09-08 16:54 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel, aurelien
"Michael S. Tsirkin" <mst@redhat.com> writes:
> On Wed, Aug 20, 2014 at 08:38:11PM +0200, Markus Armbruster wrote:
>> 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>
>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
Michael, can you take this through your tree?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 1/1] loader: g_realloc(p, 0) frees and returns NULL, simplify
2014-09-08 16:54 ` Markus Armbruster
@ 2014-09-17 7:35 ` Markus Armbruster
0 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2014-09-17 7:35 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel, aurelien
Ping?
Markus Armbruster <armbru@redhat.com> writes:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
>
>> On Wed, Aug 20, 2014 at 08:38:11PM +0200, Markus Armbruster wrote:
>>> 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>
>>
>> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>
> Michael, can you take this through your tree?
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-09-17 7:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-20 18:38 [Qemu-devel] [PATCH 1/1] loader: g_realloc(p, 0) frees and returns NULL, simplify Markus Armbruster
2014-08-20 18:49 ` Eric Blake
2014-08-20 21:22 ` Michael S. Tsirkin
2014-09-08 16:54 ` Markus Armbruster
2014-09-17 7:35 ` Markus Armbruster
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).