[libvirt] [PATCH] qemu: Avoid comparing size_t with -1

Jiri Denemark posted 1 patch 6 years, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/cfefc9e9d7b50d2155a995342d4409767c3e564f.1512999444.git.jdenemar@redhat.com
src/qemu/qemu_capabilities.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] qemu: Avoid comparing size_t with -1
Posted by Jiri Denemark 6 years, 4 months ago
ncpus would be -1 on error and the cleanup for loop would not be skipped
in this case.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_capabilities.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 8c65de956e..9673ef857b 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2965,7 +2965,7 @@ virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon)
     size_t i;
 
     if ((ncpus = qemuMonitorGetCPUDefinitions(mon, &cpus)) < 0)
-        goto error;
+        return NULL;
 
     if (!(models = virDomainCapsCPUModelsNew(ncpus)))
         goto error;
-- 
2.15.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Avoid comparing size_t with -1
Posted by John Ferlan 6 years, 4 months ago

On 12/11/2017 08:37 AM, Jiri Denemark wrote:
> ncpus would be -1 on error and the cleanup for loop would not be skipped
> in this case.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/qemu/qemu_capabilities.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list