[PATCH v2 5/7] vz: reset errors after ignoring return values

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

 



If we are going to ignore return value of a functions
that can raise an error, it's not enough to use ignore_value
construction. We should explicitly call virResetLastError

Signed-off-by: Maxim Nestratov <mnestratov@xxxxxxxxxxxxx>
---
 src/vz/vz_driver.c | 5 +++++
 src/vz/vz_sdk.c    | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index cf4b9e8..2ed12db 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -331,6 +331,11 @@ vzDriverObjNew(void)
 
     driver->hostsysinfo = virSysinfoRead();
     ignore_value(prlsdkLoadDomains(driver));
+
+    /* As far as waitDomainJob finally calls virReportErrorHelper
+     * and we are not going to report it, reset it expicitly*/
+    virResetLastError();
+
     return driver;
 }
 
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 952008e..999fce1 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -3114,6 +3114,9 @@ static int prlsdkConfigureGateways(PRL_HANDLE sdknet, virDomainNetDefPtr net)
                                  ? VIR_SOCKET_ADDR_IPV4_ALL
                                  : VIR_SOCKET_ADDR_IPV6_ALL),
                                 VIR_SOCKET_ADDR_FAMILY(addrdst)));
+        /* virSocketAddrParse raises an error
+         * and we are not going to report it, reset it expicitly*/
+        virResetLastError();
 
         if (!virSocketAddrEqual(addrdst, &zero)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -3360,6 +3363,10 @@ prlsdkCleanupBridgedNet(vzDriverPtr driver,
     job = PrlSrv_DeleteVirtualNetwork(driver->server, vnet, 0);
     ignore_value(waitDomainJob(job, dom));
 
+    /* As far as waitDomainJob finally calls virReportErrorHelper
+     * and we are not going to report it, reset it expicitly*/
+    virResetLastError();
+
  cleanup:
     PrlHandle_Free(vnet);
 }
-- 
1.8.3.1

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]