[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 20/26] qemu: Resolve Coverity NEGATIVE_RETURNS



In qemuProcessInitPCIAddresses() if qemuMonitorGetAllPCIAddresses()
returns a negative (or zero) value, then no need to call the
qemuProcessDetectPCIAddresses().

Signed-off-by: John Ferlan <jferlan redhat com>
---
 src/qemu/qemu_process.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 38ed3fe..e48a6a1 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2721,7 +2721,7 @@ qemuProcessInitPCIAddresses(virQEMUDriverPtr driver,
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
     int naddrs;
-    int ret;
+    int ret = -1;
     qemuMonitorPCIAddress *addrs = NULL;
 
     if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
@@ -2730,7 +2730,8 @@ qemuProcessInitPCIAddresses(virQEMUDriverPtr driver,
                                            &addrs);
     qemuDomainObjExitMonitor(driver, vm);
 
-    ret = qemuProcessDetectPCIAddresses(vm, addrs, naddrs);
+    if (naddrs > 0)
+        ret = qemuProcessDetectPCIAddresses(vm, addrs, naddrs);
 
     VIR_FREE(addrs);
 
-- 
1.9.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]