[libvirt] [PATCH] qemu: Don't allocate zero bytes

--- src/qemu/qemu_conf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 38eb3fd..92a9348 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -836,7 +836,7 @@ qemudCapsInitGuest(virCapsPtr caps, return -1; } - if (VIR_ALLOC_N(machines, nmachines) < 0) { + if (VIR_ALLOC_N(machines, 1) < 0) { virReportOOMError(NULL); VIR_FREE(machine->name); VIR_FREE(machine); -- 1.6.3.3

On Wed, Jan 20, 2010 at 02:45:19AM +0100, Matthias Bolte wrote:
--- src/qemu/qemu_conf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 38eb3fd..92a9348 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -836,7 +836,7 @@ qemudCapsInitGuest(virCapsPtr caps, return -1; }
- if (VIR_ALLOC_N(machines, nmachines) < 0) { + if (VIR_ALLOC_N(machines, 1) < 0) { virReportOOMError(NULL); VIR_FREE(machine->name); VIR_FREE(machine);
Hum, it's more serious than that apparently since we're doing machines[0] = machine; nmachines = 1; just after the allocation. Seems to me that moving the nmachines = 1; is a bit easier to understand and more natural, but ACK either way Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

2010/1/20 Daniel Veillard <veillard@redhat.com>:
On Wed, Jan 20, 2010 at 02:45:19AM +0100, Matthias Bolte wrote:
--- src/qemu/qemu_conf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 38eb3fd..92a9348 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -836,7 +836,7 @@ qemudCapsInitGuest(virCapsPtr caps, return -1; }
- if (VIR_ALLOC_N(machines, nmachines) < 0) { + if (VIR_ALLOC_N(machines, 1) < 0) { virReportOOMError(NULL); VIR_FREE(machine->name); VIR_FREE(machine);
Hum, it's more serious than that apparently since we're doing machines[0] = machine; nmachines = 1; just after the allocation.
Seems to me that moving the nmachines = 1; is a bit easier to understand and more natural, but ACK either way
Daniel
You're right moving nmachines = 1 before the allocation is better. I'll change the patch to do that and push it. Matthias
participants (2)
-
Daniel Veillard
-
Matthias Bolte