[libvirt] [PATCH] Write error check conditionals in more compact form for dispatcher

Daniel P. Berrange berrange at redhat.com
Wed Apr 13 18:14:08 UTC 2011


Replace cases of

     type = virConnectGetType(conn);
     if (type == NULL)
         goto cleanup;

With

     if (!(type = virConnectGetType(conn)))
         goto cleanup;

* daemon/remote.c: Write error checks in compat form
---
 daemon/remote.c |  795 +++++++++++++++++++------------------------------------
 1 files changed, 278 insertions(+), 517 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 247a226..66df9f7 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -473,9 +473,7 @@ remoteDispatchSupportsFeature(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    ret->supported = virDrvSupportsFeature(conn, args->feature);
-
-    if (ret->supported < 0)
+    if ((ret->supported = virDrvSupportsFeature(conn, args->feature)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -502,15 +500,13 @@ remoteDispatchGetType(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    type = virConnectGetType(conn);
-    if (type == NULL)
+    if (!(type = virConnectGetType(conn)))
         goto cleanup;
 
     /* We have to strdup because remoteDispatchClientRequest will
      * free this string after it's been serialised.
      */
-    ret->type = strdup(type);
-    if (!ret->type) {
+    if (!(ret->type = strdup(type))) {
         virReportOOMError();
         goto cleanup;
     }
@@ -598,8 +594,7 @@ remoteDispatchGetHostname(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    hostname = virConnectGetHostname(conn);
-    if (hostname == NULL)
+    if (!(hostname = virConnectGetHostname(conn)))
         goto cleanup;
 
     ret->hostname = hostname;
@@ -628,8 +623,7 @@ remoteDispatchGetUri(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    uri = virConnectGetURI(conn);
-    if (uri == NULL)
+    if (!(uri = virConnectGetURI(conn)))
         goto cleanup;
 
     ret->uri = uri;
@@ -660,8 +654,7 @@ remoteDispatchGetSysinfo(struct qemud_server *server ATTRIBUTE_UNUSED,
     }
 
     flags = args->flags;
-    sysinfo = virConnectGetSysinfo(conn, flags);
-    if (sysinfo == NULL)
+    if (!(sysinfo = virConnectGetSysinfo(conn, flags)))
         goto cleanup;
 
     ret->sysinfo = sysinfo;
@@ -691,8 +684,7 @@ remoteDispatchGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
     }
 
     type = args->type ? *args->type : NULL;
-    ret->max_vcpus = virConnectGetMaxVcpus(conn, type);
-    if (ret->max_vcpus < 0)
+    if ((ret->max_vcpus = virConnectGetMaxVcpus(conn, type)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -757,8 +749,7 @@ remoteDispatchGetCapabilities(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    caps = virConnectGetCapabilities(conn);
-    if (caps == NULL)
+    if (!(caps = virConnectGetCapabilities(conn)))
         goto cleanup;
 
     ret->capabilities = caps;
@@ -779,7 +770,7 @@ remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSE
                                      remote_node_get_cells_free_memory_args *args,
                                      remote_node_get_cells_free_memory_ret *ret)
 {
-    int err;
+    int len;
     int rv = -1;
 
     if (!conn) {
@@ -799,13 +790,13 @@ remoteDispatchNodeGetCellsFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSE
         goto cleanup;
     }
 
-    err = virNodeGetCellsFreeMemory(conn,
+    len = virNodeGetCellsFreeMemory(conn,
                                     (unsigned long long *)ret->freeMems.freeMems_val,
                                     args->startCell,
                                     args->maxCells);
-    if (err <= 0)
+    if (len <= 0)
         goto cleanup;
-    ret->freeMems.freeMems_len = err;
+    ret->freeMems.freeMems_len = len;
 
     rv = 0;
 
@@ -835,8 +826,7 @@ remoteDispatchNodeGetFreeMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    freeMem = virNodeGetFreeMemory(conn);
-    if (freeMem == 0)
+    if ((freeMem = virNodeGetFreeMemory(conn)) == 0)
         goto cleanup;
     ret->freeMem = freeMem;
     rv = 0;
@@ -867,12 +857,10 @@ remoteDispatchDomainGetSchedulerType(struct qemud_server *server ATTRIBUTE_UNUSE
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    type = virDomainGetSchedulerType(dom, &nparams);
-    if (type == NULL)
+    if (!(type = virDomainGetSchedulerType(dom, &nparams)))
         goto cleanup;
 
     ret->type = type;
@@ -898,7 +886,7 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
 {
     virDomainPtr dom = NULL;
     virSchedParameterPtr params;
-    int i, r, nparams;
+    int i, nparams;
     int rv = -1;
 
     if (!conn) {
@@ -917,12 +905,10 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    r = virDomainGetSchedulerParameters(dom, params, &nparams);
-    if (r < 0)
+    if (virDomainGetSchedulerParameters(dom, params, &nparams) < 0)
         goto cleanup;
 
     /* Serialise the scheduler parameters. */
@@ -984,7 +970,7 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
                                            void *ret ATTRIBUTE_UNUSED)
 {
     virDomainPtr dom = NULL;
-    int i, r, nparams;
+    int i, nparams;
     virSchedParameterPtr params;
     int rv = -1;
 
@@ -1028,12 +1014,10 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
         }
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    r = virDomainSetSchedulerParameters(dom, params, nparams);
-    if (r < 0)
+    if (virDomainSetSchedulerParameters(dom, params, nparams) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1066,8 +1050,7 @@ remoteDispatchDomainBlockStats(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
     path = args->path;
 
@@ -1109,8 +1092,7 @@ remoteDispatchDomainInterfaceStats(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
     path = args->path;
 
@@ -1161,8 +1143,7 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     /* Allocate stats array for making dispatch call */
@@ -1219,8 +1200,7 @@ remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
     path = args->path;
     offset = args->offset;
@@ -1275,8 +1255,7 @@ remoteDispatchDomainMemoryPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
     offset = args->offset;
     size = args->size;
@@ -1329,8 +1308,7 @@ remoteDispatchDomainAttachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainAttachDevice(dom, args->xml) < 0)
@@ -1363,8 +1341,7 @@ remoteDispatchDomainAttachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainAttachDeviceFlags(dom, args->xml, args->flags) < 0)
@@ -1397,8 +1374,7 @@ remoteDispatchDomainUpdateDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainUpdateDeviceFlags(dom, args->xml, args->flags) < 0)
@@ -1431,8 +1407,7 @@ remoteDispatchDomainCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainCreate(dom) < 0)
@@ -1460,8 +1435,7 @@ remoteDispatchDomainCreateWithFlags(struct qemud_server *server ATTRIBUTE_UNUSED
     int rv = -1;
     virDomainPtr dom = NULL;
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainCreateWithFlags(dom, args->flags) < 0)
@@ -1496,8 +1470,7 @@ remoteDispatchDomainCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = virDomainCreateXML(conn, args->xml_desc, args->flags);
-    if (dom == NULL)
+    if (!(dom = virDomainCreateXML(conn, args->xml_desc, args->flags)))
         goto cleanup;
 
     make_nonnull_domain(&ret->dom, dom);
@@ -1529,8 +1502,7 @@ remoteDispatchDomainDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = virDomainDefineXML(conn, args->xml);
-    if (dom == NULL)
+    if (!(dom = virDomainDefineXML(conn, args->xml)))
         goto cleanup;
 
     make_nonnull_domain(&ret->dom, dom);
@@ -1562,8 +1534,7 @@ remoteDispatchDomainDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainDestroy(dom) < 0)
@@ -1596,8 +1567,7 @@ remoteDispatchDomainDetachDevice(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainDetachDevice(dom, args->xml) < 0)
@@ -1630,8 +1600,7 @@ remoteDispatchDomainDetachDeviceFlags(struct qemud_server *server ATTRIBUTE_UNUS
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainDetachDeviceFlags(dom, args->xml, args->flags) < 0)
@@ -1664,13 +1633,11 @@ remoteDispatchDomainDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     /* remoteDispatchClientRequest will free this. */
-    ret->xml = virDomainGetXMLDesc(dom, args->flags);
-    if (!ret->xml)
+    if (!(ret->xml = virDomainGetXMLDesc(dom, args->flags)))
         goto cleanup;
 
     rv = 0;
@@ -1700,12 +1667,12 @@ remoteDispatchDomainXmlFromNative(struct qemud_server *server ATTRIBUTE_UNUSED,
     }
 
     /* remoteDispatchClientRequest will free this. */
-    ret->domainXml = virConnectDomainXMLFromNative(conn,
-                                                   args->nativeFormat,
-                                                   args->nativeConfig,
-                                                   args->flags);
-    if (!ret->domainXml)
+    if (!(ret->domainXml = virConnectDomainXMLFromNative(conn,
+                                                         args->nativeFormat,
+                                                         args->nativeConfig,
+                                                         args->flags)))
         goto cleanup;
+
     rv = 0;
 
 cleanup:
@@ -1731,12 +1698,12 @@ remoteDispatchDomainXmlToNative(struct qemud_server *server ATTRIBUTE_UNUSED,
     }
 
     /* remoteDispatchClientRequest will free this. */
-    ret->nativeConfig = virConnectDomainXMLToNative(conn,
-                                                    args->nativeFormat,
-                                                    args->domainXml,
-                                                    args->flags);
-    if (!ret->nativeConfig)
+    if (!(ret->nativeConfig = virConnectDomainXMLToNative(conn,
+                                                          args->nativeFormat,
+                                                          args->domainXml,
+                                                          args->flags)))
         goto cleanup;
+
     rv = 0;
 
 cleanup:
@@ -1763,8 +1730,7 @@ remoteDispatchDomainGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainGetAutostart(dom, &ret->autostart) < 0)
@@ -1798,8 +1764,7 @@ remoteDispatchDomainGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainGetInfo(dom, &info) < 0)
@@ -1838,12 +1803,10 @@ remoteDispatchDomainGetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    ret->memory = virDomainGetMaxMemory(dom);
-    if (ret->memory == 0)
+    if ((ret->memory = virDomainGetMaxMemory(dom)) == 0)
         goto cleanup;
 
     rv = 0;
@@ -1873,12 +1836,10 @@ remoteDispatchDomainGetMaxVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    ret->num = virDomainGetMaxVcpus(dom);
-    if (ret->num < 0)
+    if ((ret->num = virDomainGetMaxVcpus(dom)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -1909,8 +1870,7 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (VIR_ALLOC(seclabel) < 0) {
@@ -2000,14 +1960,13 @@ remoteDispatchDomainGetOsType(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     /* remoteDispatchClientRequest will free this */
-    ret->type = virDomainGetOSType(dom);
-    if (ret->type == NULL)
+    if (!(ret->type = virDomainGetOSType(dom)))
         goto cleanup;
+
     rv = 0;
 
 cleanup:
@@ -2038,8 +1997,7 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (args->maxinfo > REMOTE_VCPUINFO_MAX) {
@@ -2059,10 +2017,9 @@ remoteDispatchDomainGetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
         VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0)
         goto no_memory;
 
-    info_len = virDomainGetVcpus(dom,
-                                 info, args->maxinfo,
-                                 cpumaps, args->maplen);
-    if (info_len < 0)
+    if ((info_len = virDomainGetVcpus(dom,
+                                      info, args->maxinfo,
+                                      cpumaps, args->maplen)) < 0)
         goto cleanup;
 
     /* Allocate the return buffer for info. */
@@ -2120,12 +2077,10 @@ remoteDispatchDomainGetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    ret->num = virDomainGetVcpusFlags(dom, args->flags);
-    if (ret->num < 0)
+    if ((ret->num = virDomainGetVcpusFlags(dom, args->flags)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -2147,7 +2102,6 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
                                    remote_domain_migrate_prepare_args *args,
                                    remote_domain_migrate_prepare_ret *ret)
 {
-    int r;
     char *cookie = NULL;
     int cookielen = 0;
     char *uri_in;
@@ -2169,10 +2123,9 @@ remoteDispatchDomainMigratePrepare(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    r = virDomainMigratePrepare(conn, &cookie, &cookielen,
+    if (virDomainMigratePrepare(conn, &cookie, &cookielen,
                                 uri_in, uri_out,
-                                args->flags, dname, args->resource);
-    if (r < 0)
+                                args->flags, dname, args->resource) < 0)
         goto cleanup;
 
     /* remoteDispatchClientRequest will free cookie, uri_out and
@@ -2205,7 +2158,6 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
                                    remote_domain_migrate_perform_args *args,
                                    void *ret ATTRIBUTE_UNUSED)
 {
-    int r;
     virDomainPtr dom = NULL;
     char *dname;
     int rv = -1;
@@ -2215,18 +2167,16 @@ remoteDispatchDomainMigratePerform(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     dname = args->dname == NULL ? NULL : *args->dname;
 
-    r = virDomainMigratePerform(dom,
+    if (virDomainMigratePerform(dom,
                                 args->cookie.cookie_val,
                                 args->cookie.cookie_len,
                                 args->uri,
-                                args->flags, dname, args->resource);
-    if (r < 0)
+                                args->flags, dname, args->resource) < 0)
         goto cleanup;
 
     rv = 0;
@@ -2256,12 +2206,11 @@ remoteDispatchDomainMigrateFinish(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    ddom = virDomainMigrateFinish(conn, args->dname,
-                                  args->cookie.cookie_val,
-                                  args->cookie.cookie_len,
-                                  args->uri,
-                                  args->flags);
-    if (ddom == NULL)
+    if (!(ddom = virDomainMigrateFinish(conn, args->dname,
+                                        args->cookie.cookie_val,
+                                        args->cookie.cookie_len,
+                                        args->uri,
+                                        args->flags)))
         goto cleanup;
 
     make_nonnull_domain(&ret->ddom, ddom);
@@ -2284,7 +2233,6 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
                                     remote_domain_migrate_prepare2_args *args,
                                     remote_domain_migrate_prepare2_ret *ret)
 {
-    int r;
     char *cookie = NULL;
     int cookielen = 0;
     char *uri_in;
@@ -2306,11 +2254,10 @@ remoteDispatchDomainMigratePrepare2(struct qemud_server *server ATTRIBUTE_UNUSED
         goto cleanup;
     }
 
-    r = virDomainMigratePrepare2(conn, &cookie, &cookielen,
+    if (virDomainMigratePrepare2(conn, &cookie, &cookielen,
                                  uri_in, uri_out,
                                  args->flags, dname, args->resource,
-                                 args->dom_xml);
-    if (r < 0)
+                                 args->dom_xml) < 0)
         goto cleanup;
 
     /* remoteDispatchClientRequest will free cookie, uri_out and
@@ -2345,13 +2292,12 @@ remoteDispatchDomainMigrateFinish2(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    ddom = virDomainMigrateFinish2(conn, args->dname,
-                                   args->cookie.cookie_val,
-                                   args->cookie.cookie_len,
-                                   args->uri,
-                                   args->flags,
-                                   args->retcode);
-    if (ddom == NULL)
+    if (!(ddom = virDomainMigrateFinish2(conn, args->dname,
+                                         args->cookie.cookie_val,
+                                         args->cookie.cookie_len,
+                                         args->uri,
+                                         args->flags,
+                                         args->retcode)))
         goto cleanup;
 
     make_nonnull_domain(&ret->ddom, ddom);
@@ -2375,7 +2321,6 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
                                          remote_domain_migrate_prepare_tunnel_args *args,
                                          void *ret ATTRIBUTE_UNUSED)
 {
-    int r;
     char *dname;
     struct qemud_client_stream *stream = NULL;
     int rv = -1;
@@ -2387,16 +2332,14 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
 
     dname = args->dname == NULL ? NULL : *args->dname;
 
-    stream = remoteCreateClientStream(conn, hdr);
-    if (!stream) {
+    if (!(stream = remoteCreateClientStream(conn, hdr))) {
         virReportOOMError();
         goto cleanup;
     }
 
-    r = virDomainMigratePrepareTunnel(conn, stream->st,
+    if (virDomainMigratePrepareTunnel(conn, stream->st,
                                       args->flags, dname, args->resource,
-                                      args->dom_xml);
-    if (r < 0)
+                                      args->dom_xml) < 0)
         goto cleanup;
 
     if (remoteAddClientStream(client, stream, 0) < 0)
@@ -2477,8 +2420,7 @@ remoteDispatchDomainLookupById(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = virDomainLookupByID(conn, args->id);
-    if (dom == NULL)
+    if (!(dom = virDomainLookupByID(conn, args->id)))
         goto cleanup;
 
     make_nonnull_domain(&ret->dom, dom);
@@ -2510,8 +2452,7 @@ remoteDispatchDomainLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = virDomainLookupByName(conn, args->name);
-    if (dom == NULL)
+    if (!(dom = virDomainLookupByName(conn, args->name)))
         goto cleanup;
 
     make_nonnull_domain(&ret->dom, dom);
@@ -2543,8 +2484,7 @@ remoteDispatchDomainLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid);
-    if (dom == NULL)
+    if (!(dom = virDomainLookupByUUID(conn, (unsigned char *) args->uuid)))
         goto cleanup;
 
     make_nonnull_domain(&ret->dom, dom);
@@ -2575,8 +2515,7 @@ remoteDispatchNumOfDefinedDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    ret->num = virConnectNumOfDefinedDomains(conn);
-    if (ret->num < 0)
+    if ((ret->num = virConnectNumOfDefinedDomains(conn)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -2604,8 +2543,7 @@ remoteDispatchDomainPinVcpu(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (args->cpumap.cpumap_len > REMOTE_CPUMAP_MAX) {
@@ -2613,10 +2551,9 @@ remoteDispatchDomainPinVcpu(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    rv = virDomainPinVcpu(dom, args->vcpu,
-                          (unsigned char *) args->cpumap.cpumap_val,
-                          args->cpumap.cpumap_len);
-    if (rv < 0)
+    if (virDomainPinVcpu(dom, args->vcpu,
+                         (unsigned char *) args->cpumap.cpumap_val,
+                         args->cpumap.cpumap_len) < 0)
         goto cleanup;
 
     rv = 0;
@@ -2646,8 +2583,7 @@ remoteDispatchDomainReboot(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainReboot(dom, args->flags) < 0)
@@ -2707,8 +2643,7 @@ remoteDispatchDomainResume(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainResume(dom) < 0)
@@ -2741,8 +2676,7 @@ remoteDispatchDomainSave(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainSave(dom, args->to) < 0)
@@ -2775,8 +2709,7 @@ remoteDispatchDomainCoreDump(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainCoreDump(dom, args->to, args->flags) < 0)
@@ -2809,8 +2742,7 @@ remoteDispatchDomainSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainSetAutostart(dom, args->autostart) < 0)
@@ -2843,8 +2775,7 @@ remoteDispatchDomainSetMaxMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainSetMaxMemory(dom, args->memory) < 0)
@@ -2877,8 +2808,7 @@ remoteDispatchDomainSetMemory(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainSetMemory(dom, args->memory) < 0)
@@ -2911,8 +2841,7 @@ remoteDispatchDomainSetMemoryFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainSetMemoryFlags(dom, args->memory, args->flags) < 0)
@@ -2941,7 +2870,7 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
                                         * args, void *ret ATTRIBUTE_UNUSED)
 {
     virDomainPtr dom = NULL;
-    int i, r, nparams;
+    int i, nparams;
     virMemoryParameterPtr params;
     unsigned int flags;
     int rv = -1;
@@ -3007,12 +2936,10 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
         }
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    r = virDomainSetMemoryParameters(dom, params, nparams, flags);
-    if (r < 0)
+    if (virDomainSetMemoryParameters(dom, params, nparams, flags) < 0)
         goto cleanup;
 
     rv = 0;
@@ -3042,7 +2969,7 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
 {
     virDomainPtr dom = NULL;
     virMemoryParameterPtr params;
-    int i, r, nparams;
+    int i, nparams;
     unsigned int flags;
     int rv = -1;
 
@@ -3063,13 +2990,12 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    r = virDomainGetMemoryParameters(dom, params, &nparams, flags);
-    if (r < 0)
+    if (virDomainGetMemoryParameters(dom, params, &nparams, flags) < 0)
         goto cleanup;
+
     /* In this case, we need to send back the number of parameters
      * supported
      */
@@ -3158,7 +3084,7 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
                                         * args, void *ret ATTRIBUTE_UNUSED)
 {
     virDomainPtr dom = NULL;
-    int i, r, nparams;
+    int i, nparams;
     virBlkioParameterPtr params;
     unsigned int flags;
     int rv = -1;
@@ -3224,12 +3150,10 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
         }
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    r = virDomainSetBlkioParameters(dom, params, nparams, flags);
-    if (r < 0)
+    if (virDomainSetBlkioParameters(dom, params, nparams, flags) < 0)
         goto cleanup;
 
     rv = 0;
@@ -3259,7 +3183,7 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
 {
     virDomainPtr dom = NULL;
     virBlkioParameterPtr params;
-    int i, r, nparams;
+    int i, nparams;
     unsigned int flags;
     int rv = -1;
 
@@ -3280,13 +3204,12 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    r = virDomainGetBlkioParameters(dom, params, &nparams, flags);
-    if (r < 0)
+    if (virDomainGetBlkioParameters(dom, params, &nparams, flags) < 0)
         goto cleanup;
+
     /* In this case, we need to send back the number of parameters
      * supported
      */
@@ -3381,8 +3304,7 @@ remoteDispatchDomainSetVcpus(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainSetVcpus(dom, args->nvcpus) < 0)
@@ -3415,8 +3337,7 @@ remoteDispatchDomainSetVcpusFlags(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainSetVcpusFlags(dom, args->nvcpus, args->flags) < 0)
@@ -3449,8 +3370,7 @@ remoteDispatchDomainShutdown(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainShutdown(dom) < 0)
@@ -3483,8 +3403,7 @@ remoteDispatchDomainSuspend(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainSuspend(dom) < 0)
@@ -3517,8 +3436,7 @@ remoteDispatchDomainUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainUndefine(dom) < 0)
@@ -3641,8 +3559,7 @@ remoteDispatchDomainManagedSave(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainManagedSave(dom, args->flags) < 0)
@@ -3675,12 +3592,10 @@ remoteDispatchDomainHasManagedSaveImage(struct qemud_server *server ATTRIBUTE_UN
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    ret->ret = virDomainHasManagedSaveImage(dom, args->flags);
-    if (ret->ret < 0)
+    if ((ret->ret = virDomainHasManagedSaveImage(dom, args->flags)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -3710,8 +3625,7 @@ remoteDispatchDomainManagedSaveRemove(struct qemud_server *server ATTRIBUTE_UNUS
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainManagedSaveRemove(dom, args->flags) < 0)
@@ -3789,8 +3703,7 @@ remoteDispatchNetworkCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    net = get_nonnull_network(conn, args->net);
-    if (net == NULL)
+    if (!(net = get_nonnull_network(conn, args->net)))
         goto cleanup;
 
     if (virNetworkCreate(net) < 0)
@@ -3823,8 +3736,7 @@ remoteDispatchNetworkCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    net = virNetworkCreateXML(conn, args->xml);
-    if (net == NULL)
+    if (!(net = virNetworkCreateXML(conn, args->xml)))
         goto cleanup;
 
     make_nonnull_network(&ret->net, net);
@@ -3856,8 +3768,7 @@ remoteDispatchNetworkDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    net = virNetworkDefineXML(conn, args->xml);
-    if (net == NULL)
+    if (!(net = virNetworkDefineXML(conn, args->xml)))
         goto cleanup;
 
     make_nonnull_network(&ret->net, net);
@@ -3889,8 +3800,7 @@ remoteDispatchNetworkDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    net = get_nonnull_network(conn, args->net);
-    if (net == NULL)
+    if (!(net = get_nonnull_network(conn, args->net)))
         goto cleanup;
 
     if (virNetworkDestroy(net) < 0)
@@ -3923,13 +3833,11 @@ remoteDispatchNetworkDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    net = get_nonnull_network(conn, args->net);
-    if (net == NULL)
+    if (!(net = get_nonnull_network(conn, args->net)))
         goto cleanup;
 
     /* remoteDispatchClientRequest will free this. */
-    ret->xml = virNetworkGetXMLDesc(net, args->flags);
-    if (!ret->xml)
+    if (!(ret->xml = virNetworkGetXMLDesc(net, args->flags)))
         goto cleanup;
 
     rv = 0;
@@ -3959,8 +3867,7 @@ remoteDispatchNetworkGetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    net = get_nonnull_network(conn, args->net);
-    if (net == NULL)
+    if (!(net = get_nonnull_network(conn, args->net)))
         goto cleanup;
 
     if (virNetworkGetAutostart(net, &ret->autostart) < 0)
@@ -3993,13 +3900,11 @@ remoteDispatchNetworkGetBridgeName(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    net = get_nonnull_network(conn, args->net);
-    if (net == NULL)
+    if (!(net = get_nonnull_network(conn, args->net)))
         goto cleanup;
 
     /* remoteDispatchClientRequest will free this. */
-    ret->name = virNetworkGetBridgeName(net);
-    if (!ret->name)
+    if (!(ret->name = virNetworkGetBridgeName(net)))
         goto cleanup;
 
     rv = 0;
@@ -4029,8 +3934,7 @@ remoteDispatchNetworkLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    net = virNetworkLookupByName(conn, args->name);
-    if (net == NULL)
+    if (!(net = virNetworkLookupByName(conn, args->name)))
         goto cleanup;
 
     make_nonnull_network(&ret->net, net);
@@ -4062,8 +3966,7 @@ remoteDispatchNetworkLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    net = virNetworkLookupByUUID(conn, (unsigned char *) args->uuid);
-    if (net == NULL)
+    if (!(net = virNetworkLookupByUUID(conn, (unsigned char *) args->uuid)))
         goto cleanup;
 
     make_nonnull_network(&ret->net, net);
@@ -4095,8 +3998,7 @@ remoteDispatchNetworkSetAutostart(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    net = get_nonnull_network(conn, args->net);
-    if (net == NULL)
+    if (!(net = get_nonnull_network(conn, args->net)))
         goto cleanup;
 
     if (virNetworkSetAutostart(net, args->autostart) < 0)
@@ -4129,8 +4031,7 @@ remoteDispatchNetworkUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    net = get_nonnull_network(conn, args->net);
-    if (net == NULL)
+    if (!(net = get_nonnull_network(conn, args->net)))
         goto cleanup;
 
     if (virNetworkUndefine(net) < 0)
@@ -4192,8 +4093,7 @@ remoteDispatchNumOfDomains(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    ret->num = virConnectNumOfDomains(conn);
-    if (ret->num < 0)
+    if ((ret->num = virConnectNumOfDomains(conn)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -4220,8 +4120,7 @@ remoteDispatchNumOfNetworks(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    ret->num = virConnectNumOfNetworks(conn);
-    if (ret->num < 0)
+    if ((ret->num = virConnectNumOfNetworks(conn)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -4250,8 +4149,7 @@ remoteDispatchNumOfInterfaces(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    ret->num = virConnectNumOfInterfaces(conn);
-    if (ret->num < 0)
+    if ((ret->num = virConnectNumOfInterfaces(conn)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -4399,8 +4297,7 @@ remoteDispatchInterfaceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED
         goto cleanup;
     }
 
-    iface = virInterfaceLookupByName(conn, args->name);
-    if (iface == NULL)
+    if (!(iface = virInterfaceLookupByName(conn, args->name)))
         goto cleanup;
 
     make_nonnull_interface(&ret->iface, iface);
@@ -4432,8 +4329,7 @@ remoteDispatchInterfaceLookupByMacString(struct qemud_server *server ATTRIBUTE_U
         goto cleanup;
     }
 
-    iface = virInterfaceLookupByMACString(conn, args->mac);
-    if (iface == NULL)
+    if (!(iface = virInterfaceLookupByMACString(conn, args->mac)))
         goto cleanup;
 
     make_nonnull_interface(&ret->iface, iface);
@@ -4465,13 +4361,11 @@ remoteDispatchInterfaceGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    iface = get_nonnull_interface(conn, args->iface);
-    if (iface == NULL)
+    if (!(iface = get_nonnull_interface(conn, args->iface)))
         goto cleanup;
 
     /* remoteDispatchClientRequest will free this. */
-    ret->xml = virInterfaceGetXMLDesc(iface, args->flags);
-    if (!ret->xml)
+    if (!(ret->xml = virInterfaceGetXMLDesc(iface, args->flags)))
         goto cleanup;
 
     rv = 0;
@@ -4501,8 +4395,7 @@ remoteDispatchInterfaceDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    iface = virInterfaceDefineXML(conn, args->xml, args->flags);
-    if (iface == NULL)
+    if (!(iface = virInterfaceDefineXML(conn, args->xml, args->flags)))
         goto cleanup;
 
     make_nonnull_interface(&ret->iface, iface);
@@ -4534,8 +4427,7 @@ remoteDispatchInterfaceUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    iface = get_nonnull_interface(conn, args->iface);
-    if (iface == NULL)
+    if (!(iface = get_nonnull_interface(conn, args->iface)))
         goto cleanup;
 
     if (virInterfaceUndefine(iface) < 0)
@@ -4568,8 +4460,7 @@ remoteDispatchInterfaceCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    iface = get_nonnull_interface(conn, args->iface);
-    if (iface == NULL)
+    if (!(iface = get_nonnull_interface(conn, args->iface)))
         goto cleanup;
 
     if (virInterfaceCreate(iface, args->flags) < 0)
@@ -4602,8 +4493,7 @@ remoteDispatchInterfaceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    iface = get_nonnull_interface(conn, args->iface);
-    if (iface == NULL)
+    if (!(iface = get_nonnull_interface(conn, args->iface)))
         goto cleanup;
 
     if (virInterfaceDestroy(iface, args->flags) < 0)
@@ -5528,12 +5418,11 @@ remoteDispatchFindStoragePoolSources(struct qemud_server *server ATTRIBUTE_UNUSE
         goto cleanup;
     }
 
-    ret->xml =
-        virConnectFindStoragePoolSources(conn,
-                                         args->type,
-                                         args->srcSpec ? *args->srcSpec : NULL,
-                                         args->flags);
-    if (ret->xml == NULL)
+    if (!(ret->xml =
+          virConnectFindStoragePoolSources(conn,
+                                           args->type,
+                                           args->srcSpec ? *args->srcSpec : NULL,
+                                           args->flags)))
         goto cleanup;
 
     rv = 0;
@@ -5562,8 +5451,7 @@ remoteDispatchStoragePoolCreate(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
     if (virStoragePoolCreate(pool, args->flags) < 0)
@@ -5596,8 +5484,7 @@ remoteDispatchStoragePoolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    pool = virStoragePoolCreateXML(conn, args->xml, args->flags);
-    if (pool == NULL)
+    if (!(pool = virStoragePoolCreateXML(conn, args->xml, args->flags)))
         goto cleanup;
 
     make_nonnull_storage_pool(&ret->pool, pool);
@@ -5629,8 +5516,7 @@ remoteDispatchStoragePoolDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    pool = virStoragePoolDefineXML(conn, args->xml, args->flags);
-    if (pool == NULL)
+    if (!(pool = virStoragePoolDefineXML(conn, args->xml, args->flags)))
         goto cleanup;
 
     make_nonnull_storage_pool(&ret->pool, pool);
@@ -5662,8 +5548,7 @@ remoteDispatchStoragePoolBuild(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
     if (virStoragePoolBuild(pool, args->flags) < 0)
@@ -5697,8 +5582,7 @@ remoteDispatchStoragePoolDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
     if (virStoragePoolDestroy(pool) < 0)
@@ -5731,8 +5615,7 @@ remoteDispatchStoragePoolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
     if (virStoragePoolDelete(pool, args->flags) < 0)
@@ -5765,8 +5648,7 @@ remoteDispatchStoragePoolRefresh(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
     if (virStoragePoolRefresh(pool, args->flags) < 0)
@@ -5800,8 +5682,7 @@ remoteDispatchStoragePoolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
     if (virStoragePoolGetInfo(pool, &info) < 0)
@@ -5839,13 +5720,11 @@ remoteDispatchStoragePoolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
     /* remoteDispatchClientRequest will free this. */
-    ret->xml = virStoragePoolGetXMLDesc(pool, args->flags);
-    if (!ret->xml)
+    if (!(ret->xml = virStoragePoolGetXMLDesc(pool, args->flags)))
         goto cleanup;
 
     rv = 0;
@@ -5875,8 +5754,7 @@ remoteDispatchStoragePoolGetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
     if (virStoragePoolGetAutostart(pool, &ret->autostart) < 0)
@@ -5910,8 +5788,7 @@ remoteDispatchStoragePoolLookupByName(struct qemud_server *server ATTRIBUTE_UNUS
         goto cleanup;
     }
 
-    pool = virStoragePoolLookupByName(conn, args->name);
-    if (pool == NULL)
+    if (!(pool = virStoragePoolLookupByName(conn, args->name)))
         goto cleanup;
 
     make_nonnull_storage_pool(&ret->pool, pool);
@@ -5943,8 +5820,7 @@ remoteDispatchStoragePoolLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUS
         goto cleanup;
     }
 
-    pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid);
-    if (pool == NULL)
+    if (!(pool = virStoragePoolLookupByUUID(conn, (unsigned char *) args->uuid)))
         goto cleanup;
 
     make_nonnull_storage_pool(&ret->pool, pool);
@@ -5977,12 +5853,10 @@ remoteDispatchStoragePoolLookupByVolume(struct qemud_server *server ATTRIBUTE_UN
         goto cleanup;
     }
 
-    vol = get_nonnull_storage_vol(conn, args->vol);
-    if (vol == NULL)
+    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
         goto cleanup;
 
-    pool = virStoragePoolLookupByVolume(vol);
-    if (pool == NULL)
+    if (!(pool = virStoragePoolLookupByVolume(vol)))
         goto cleanup;
 
     make_nonnull_storage_pool(&ret->pool, pool);
@@ -6016,8 +5890,7 @@ remoteDispatchStoragePoolSetAutostart(struct qemud_server *server ATTRIBUTE_UNUS
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
     if (virStoragePoolSetAutostart(pool, args->autostart) < 0)
@@ -6050,8 +5923,7 @@ remoteDispatchStoragePoolUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
     if (virStoragePoolUndefine(pool) < 0)
@@ -6083,8 +5955,7 @@ remoteDispatchNumOfStoragePools(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    ret->num = virConnectNumOfStoragePools(conn);
-    if (ret->num < 0)
+    if ((ret->num = virConnectNumOfStoragePools(conn)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -6111,8 +5982,7 @@ remoteDispatchNumOfDefinedStoragePools(struct qemud_server *server ATTRIBUTE_UNU
         goto cleanup;
     }
 
-    ret->num = virConnectNumOfDefinedStoragePools(conn);
-    if (ret->num < 0)
+    if ((ret->num = virConnectNumOfDefinedStoragePools(conn)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -6147,8 +6017,7 @@ remoteDispatchStoragePoolListVolumes(struct qemud_server *server ATTRIBUTE_UNUSE
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
     /* Allocate return buffer. */
@@ -6193,12 +6062,10 @@ remoteDispatchStoragePoolNumOfVolumes(struct qemud_server *server ATTRIBUTE_UNUS
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    ret->num = virStoragePoolNumOfVolumes(pool);
-    if (ret->num < 0)
+    if ((ret->num = virStoragePoolNumOfVolumes(pool)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -6236,12 +6103,10 @@ remoteDispatchStorageVolCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    vol = virStorageVolCreateXML(pool, args->xml, args->flags);
-    if (vol == NULL)
+    if (!(vol = virStorageVolCreateXML(pool, args->xml, args->flags)))
         goto cleanup;
 
     make_nonnull_storage_vol(&ret->vol, vol);
@@ -6276,17 +6141,14 @@ remoteDispatchStorageVolCreateXmlFrom(struct qemud_server *server ATTRIBUTE_UNUS
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    clonevol = get_nonnull_storage_vol(conn, args->clonevol);
-    if (clonevol == NULL)
+    if (!(clonevol = get_nonnull_storage_vol(conn, args->clonevol)))
         goto cleanup;
 
-    newvol = virStorageVolCreateXMLFrom(pool, args->xml, clonevol,
-                                        args->flags);
-    if (newvol == NULL)
+    if (!(newvol = virStorageVolCreateXMLFrom(pool, args->xml, clonevol,
+                                              args->flags)))
         goto cleanup;
 
     make_nonnull_storage_vol(&ret->vol, newvol);
@@ -6321,8 +6183,7 @@ remoteDispatchStorageVolDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    vol = get_nonnull_storage_vol(conn, args->vol);
-    if (vol == NULL)
+    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
         goto cleanup;
 
     if (virStorageVolDelete(vol, args->flags) < 0)
@@ -6355,8 +6216,7 @@ remoteDispatchStorageVolWipe(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    vol = get_nonnull_storage_vol(conn, args->vol);
-    if (vol == NULL)
+    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
         goto cleanup;
 
     if (virStorageVolWipe(vol, args->flags) < 0)
@@ -6390,8 +6250,7 @@ remoteDispatchStorageVolGetInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    vol = get_nonnull_storage_vol(conn, args->vol);
-    if (vol == NULL)
+    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
         goto cleanup;
 
     if (virStorageVolGetInfo(vol, &info) < 0)
@@ -6428,13 +6287,11 @@ remoteDispatchStorageVolDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    vol = get_nonnull_storage_vol(conn, args->vol);
-    if (vol == NULL)
+    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
         goto cleanup;
 
     /* remoteDispatchClientRequest will free this. */
-    ret->xml = virStorageVolGetXMLDesc(vol, args->flags);
-    if (!ret->xml)
+    if (!(ret->xml = virStorageVolGetXMLDesc(vol, args->flags)))
         goto cleanup;
 
     rv = 0;
@@ -6465,13 +6322,11 @@ remoteDispatchStorageVolGetPath(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    vol = get_nonnull_storage_vol(conn, args->vol);
-    if (vol == NULL)
+    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
         goto cleanup;
 
     /* remoteDispatchClientRequest will free this. */
-    ret->name = virStorageVolGetPath(vol);
-    if (!ret->name)
+    if (!(ret->name = virStorageVolGetPath(vol)))
         goto cleanup;
 
     rv = 0;
@@ -6503,12 +6358,10 @@ remoteDispatchStorageVolLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    vol = virStorageVolLookupByName(pool, args->name);
-    if (vol == NULL)
+    if (!(vol = virStorageVolLookupByName(pool, args->name)))
         goto cleanup;
 
     make_nonnull_storage_vol(&ret->vol, vol);
@@ -6542,8 +6395,7 @@ remoteDispatchStorageVolLookupByKey(struct qemud_server *server ATTRIBUTE_UNUSED
         goto cleanup;
     }
 
-    vol = virStorageVolLookupByKey(conn, args->key);
-    if (vol == NULL)
+    if (!(vol = virStorageVolLookupByKey(conn, args->key)))
         goto cleanup;
 
     make_nonnull_storage_vol(&ret->vol, vol);
@@ -6576,8 +6428,7 @@ remoteDispatchStorageVolLookupByPath(struct qemud_server *server ATTRIBUTE_UNUSE
         goto cleanup;
     }
 
-    vol = virStorageVolLookupByPath(conn, args->path);
-    if (vol == NULL)
+    if (!(vol = virStorageVolLookupByPath(conn, args->path)))
         goto cleanup;
 
     make_nonnull_storage_vol(&ret->vol, vol);
@@ -6613,10 +6464,9 @@ remoteDispatchNodeNumOfDevices(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    ret->num = virNodeNumOfDevices(conn,
-                                   args->cap ? *args->cap : NULL,
-                                   args->flags);
-    if (ret->num < 0)
+    if ((ret->num = virNodeNumOfDevices(conn,
+                                        args->cap ? *args->cap : NULL,
+                                        args->flags)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -6692,8 +6542,7 @@ remoteDispatchNodeDeviceLookupByName(struct qemud_server *server ATTRIBUTE_UNUSE
         goto cleanup;
     }
 
-    dev = virNodeDeviceLookupByName(conn, args->name);
-    if (dev == NULL)
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
         goto cleanup;
 
     make_nonnull_node_device(&ret->dev, dev);
@@ -6726,13 +6575,11 @@ remoteDispatchNodeDeviceDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dev = virNodeDeviceLookupByName(conn, args->name);
-    if (dev == NULL)
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
         goto cleanup;
 
     /* remoteDispatchClientRequest will free this. */
-    ret->xml = virNodeDeviceGetXMLDesc(dev, args->flags);
-    if (!ret->xml)
+    if (!(ret->xml = virNodeDeviceGetXMLDesc(dev, args->flags)))
         goto cleanup;
 
     rv = 0;
@@ -6764,8 +6611,7 @@ remoteDispatchNodeDeviceGetParent(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dev = virNodeDeviceLookupByName(conn, args->name);
-    if (dev == NULL)
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
         goto cleanup;
 
     parent = virNodeDeviceGetParent(dev);
@@ -6815,12 +6661,10 @@ remoteDispatchNodeDeviceNumOfCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dev = virNodeDeviceLookupByName(conn, args->name);
-    if (dev == NULL)
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
         goto cleanup;
 
-    ret->num = virNodeDeviceNumOfCaps(dev);
-    if (ret->num < 0)
+    if ((ret->num = virNodeDeviceNumOfCaps(dev)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -6852,8 +6696,7 @@ remoteDispatchNodeDeviceListCaps(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dev = virNodeDeviceLookupByName(conn, args->name);
-    if (dev == NULL)
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
         goto cleanup;
 
     if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
@@ -6904,8 +6747,7 @@ remoteDispatchNodeDeviceDettach(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dev = virNodeDeviceLookupByName(conn, args->name);
-    if (dev == NULL)
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
         goto cleanup;
 
     if (virNodeDeviceDettach(dev) < 0)
@@ -6939,8 +6781,7 @@ remoteDispatchNodeDeviceReAttach(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dev = virNodeDeviceLookupByName(conn, args->name);
-    if (dev == NULL)
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
         goto cleanup;
 
     if (virNodeDeviceReAttach(dev) < 0)
@@ -6974,8 +6815,7 @@ remoteDispatchNodeDeviceReset(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dev = virNodeDeviceLookupByName(conn, args->name);
-    if (dev == NULL)
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
         goto cleanup;
 
     if (virNodeDeviceReset(dev) < 0)
@@ -7009,8 +6849,7 @@ remoteDispatchNodeDeviceCreateXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags);
-    if (dev == NULL)
+    if (!(dev = virNodeDeviceCreateXML(conn, args->xml_desc, args->flags)))
         goto cleanup;
 
     make_nonnull_node_device(&ret->dev, dev);
@@ -7043,8 +6882,7 @@ remoteDispatchNodeDeviceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dev = virNodeDeviceLookupByName(conn, args->name);
-    if (dev == NULL)
+    if (!(dev = virNodeDeviceLookupByName(conn, args->name)))
         goto cleanup;
 
     if (virNodeDeviceDestroy(dev) < 0)
@@ -7077,12 +6915,10 @@ static int remoteDispatchStorageVolUpload(struct qemud_server *server ATTRIBUTE_
         goto cleanup;
     }
 
-    vol = get_nonnull_storage_vol(conn, args->vol);
-    if (vol == NULL)
+    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
         goto cleanup;
 
-    stream = remoteCreateClientStream(conn, hdr);
-    if (!stream)
+    if (!(stream = remoteCreateClientStream(conn, hdr)))
         goto cleanup;
 
     if (virStorageVolUpload(vol, stream->st,
@@ -7124,12 +6960,10 @@ static int remoteDispatchStorageVolDownload(struct qemud_server *server ATTRIBUT
         goto cleanup;
     }
 
-    vol = get_nonnull_storage_vol(conn, args->vol);
-    if (vol == NULL)
+    if (!(vol = get_nonnull_storage_vol(conn, args->vol)))
         goto cleanup;
 
-    stream = remoteCreateClientStream(conn, hdr);
-    if (!stream)
+    if (!(stream = remoteCreateClientStream(conn, hdr)))
         goto cleanup;
 
     if (virStorageVolDownload(vol, stream->st,
@@ -7311,8 +7145,7 @@ remoteDispatchNumOfSecrets(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    ret->num = virConnectNumOfSecrets(conn);
-    if (ret->num < 0)
+    if ((ret->num = virConnectNumOfSecrets(conn)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -7384,8 +7217,7 @@ remoteDispatchSecretDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    secret = virSecretDefineXML(conn, args->xml, args->flags);
-    if (secret == NULL)
+    if (!(secret = virSecretDefineXML(conn, args->xml, args->flags)))
         goto cleanup;
 
     make_nonnull_secret(&ret->secret, secret);
@@ -7418,12 +7250,10 @@ remoteDispatchSecretGetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    secret = get_nonnull_secret(conn, args->secret);
-    if (secret == NULL)
+    if (!(secret = get_nonnull_secret(conn, args->secret)))
         goto cleanup;
 
-    value = virSecretGetValue(secret, &value_size, args->flags);
-    if (value == NULL)
+    if (!(value = virSecretGetValue(secret, &value_size, args->flags)))
         goto cleanup;
 
     ret->value.value_len = value_size;
@@ -7456,11 +7286,9 @@ remoteDispatchSecretGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    secret = get_nonnull_secret(conn, args->secret);
-    if (secret == NULL)
+    if (!(secret = get_nonnull_secret(conn, args->secret)))
         goto cleanup;
-    ret->xml = virSecretGetXMLDesc(secret, args->flags);
-    if (ret->xml == NULL)
+    if (!(ret->xml = virSecretGetXMLDesc(secret, args->flags)))
         goto cleanup;
 
     rv = 0;
@@ -7490,8 +7318,7 @@ remoteDispatchSecretLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid);
-    if (secret == NULL)
+    if (!(secret = virSecretLookupByUUID(conn, (unsigned char *)args->uuid)))
         goto cleanup;
 
     make_nonnull_secret(&ret->secret, secret);
@@ -7523,8 +7350,7 @@ remoteDispatchSecretSetValue(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    secret = get_nonnull_secret(conn, args->secret);
-    if (secret == NULL)
+    if (!(secret = get_nonnull_secret(conn, args->secret)))
         goto cleanup;
     if (virSecretSetValue(secret, (const unsigned char *)args->value.value_val,
                           args->value.value_len, args->flags) < 0)
@@ -7557,8 +7383,7 @@ remoteDispatchSecretUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    secret = get_nonnull_secret(conn, args->secret);
-    if (secret == NULL)
+    if (!(secret = get_nonnull_secret(conn, args->secret)))
         goto cleanup;
     if (virSecretUndefine(secret) < 0)
         goto cleanup;
@@ -7590,8 +7415,7 @@ remoteDispatchSecretLookupByUsage(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    secret = virSecretLookupByUsage(conn, args->usageType, args->usageID);
-    if (secret == NULL)
+    if (!(secret = virSecretLookupByUsage(conn, args->usageType, args->usageID)))
         goto cleanup;
 
     make_nonnull_secret(&ret->secret, secret);
@@ -7623,13 +7447,10 @@ static int remoteDispatchDomainIsActive(struct qemud_server *server ATTRIBUTE_UN
         goto cleanup;
     }
 
-    domain = get_nonnull_domain(conn, args->dom);
-    if (domain == NULL)
+    if (!(domain = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    ret->active = virDomainIsActive(domain);
-
-    if (ret->active < 0)
+    if ((ret->active = virDomainIsActive(domain)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -7658,13 +7479,10 @@ static int remoteDispatchDomainIsPersistent(struct qemud_server *server ATTRIBUT
         goto cleanup;
     }
 
-    domain = get_nonnull_domain(conn, args->dom);
-    if (domain == NULL)
+    if (!(domain = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    ret->persistent = virDomainIsPersistent(domain);
-
-    if (ret->persistent < 0)
+    if ((ret->persistent = virDomainIsPersistent(domain)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -7693,13 +7511,10 @@ static int remoteDispatchDomainIsUpdated(struct qemud_server *server ATTRIBUTE_U
         goto cleanup;
     }
 
-    domain = get_nonnull_domain(conn, args->dom);
-    if (domain == NULL)
+    if (!(domain = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    ret->updated = virDomainIsUpdated(domain);
-
-    if (ret->updated < 0)
+    if ((ret->updated = virDomainIsUpdated(domain)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -7728,13 +7543,10 @@ static int remoteDispatchInterfaceIsActive(struct qemud_server *server ATTRIBUTE
         goto cleanup;
     }
 
-    iface = get_nonnull_interface(conn, args->iface);
-    if (iface == NULL)
+    if (!(iface = get_nonnull_interface(conn, args->iface)))
         goto cleanup;
 
-    ret->active = virInterfaceIsActive(iface);
-
-    if (ret->active < 0)
+    if ((ret->active = virInterfaceIsActive(iface)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -7763,13 +7575,10 @@ static int remoteDispatchNetworkIsActive(struct qemud_server *server ATTRIBUTE_U
         goto cleanup;
     }
 
-    network = get_nonnull_network(conn, args->net);
-    if (network == NULL)
+    if (!(network = get_nonnull_network(conn, args->net)))
         goto cleanup;
 
-    ret->active = virNetworkIsActive(network);
-
-    if (ret->active < 0)
+    if ((ret->active = virNetworkIsActive(network)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -7798,13 +7607,10 @@ static int remoteDispatchNetworkIsPersistent(struct qemud_server *server ATTRIBU
         goto cleanup;
     }
 
-    network = get_nonnull_network(conn, args->net);
-    if (network == NULL)
+    if (!(network = get_nonnull_network(conn, args->net)))
         goto cleanup;
 
-    ret->persistent = virNetworkIsPersistent(network);
-
-    if (ret->persistent < 0)
+    if ((ret->persistent = virNetworkIsPersistent(network)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -7833,13 +7639,10 @@ static int remoteDispatchStoragePoolIsActive(struct qemud_server *server ATTRIBU
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    ret->active = virStoragePoolIsActive(pool);
-
-    if (ret->active < 0)
+    if ((ret->active = virStoragePoolIsActive(pool)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -7868,13 +7671,10 @@ static int remoteDispatchStoragePoolIsPersistent(struct qemud_server *server ATT
         goto cleanup;
     }
 
-    pool = get_nonnull_storage_pool(conn, args->pool);
-    if (pool == NULL)
+    if (!(pool = get_nonnull_storage_pool(conn, args->pool)))
         goto cleanup;
 
-    ret->persistent = virStoragePoolIsPersistent(pool);
-
-    if (ret->persistent < 0)
+    if ((ret->persistent = virStoragePoolIsPersistent(pool)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -7903,9 +7703,7 @@ static int remoteDispatchIsSecure(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    ret->secure = virConnectIsSecure(conn);
-
-    if (ret->secure < 0)
+    if ((ret->secure = virConnectIsSecure(conn)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -7934,8 +7732,7 @@ remoteDispatchCpuCompare(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    result = virConnectCompareCPU(conn, args->xml, args->flags);
-    if (result == VIR_CPU_COMPARE_ERROR)
+    if ((result = virConnectCompareCPU(conn, args->xml, args->flags)) == VIR_CPU_COMPARE_ERROR)
         goto cleanup;
 
     ret->result = result;
@@ -7965,11 +7762,10 @@ remoteDispatchCpuBaseline(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    cpu = virConnectBaselineCPU(conn,
-                                (const char **) args->xmlCPUs.xmlCPUs_val,
-                                args->xmlCPUs.xmlCPUs_len,
-                                args->flags);
-    if (cpu == NULL)
+    if (!(cpu = virConnectBaselineCPU(conn,
+                                      (const char **) args->xmlCPUs.xmlCPUs_val,
+                                      args->xmlCPUs.xmlCPUs_len,
+                                      args->flags)))
         goto cleanup;
 
     ret->cpu = cpu;
@@ -8001,8 +7797,7 @@ remoteDispatchDomainGetJobInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainGetJobInfo(dom, &info) < 0)
@@ -8049,8 +7844,7 @@ remoteDispatchDomainAbortJob(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainAbortJob(dom) < 0)
@@ -8084,8 +7878,7 @@ remoteDispatchDomainMigrateSetMaxDowntime(struct qemud_server *server ATTRIBUTE_
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainMigrateSetMaxDowntime(dom, args->downtime, args->flags) < 0)
@@ -8118,8 +7911,7 @@ remoteDispatchDomainMigrateSetMaxSpeed(struct qemud_server *server ATTRIBUTE_UNU
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainMigrateSetMaxSpeed(dom, args->bandwidth, args->flags) < 0)
@@ -8153,12 +7945,10 @@ remoteDispatchDomainSnapshotCreateXml(struct qemud_server *server ATTRIBUTE_UNUS
         goto cleanup;
     }
 
-    domain = get_nonnull_domain(conn, args->domain);
-    if (domain == NULL)
+    if (!(domain = get_nonnull_domain(conn, args->domain)))
         goto cleanup;
 
-    snapshot = virDomainSnapshotCreateXML(domain, args->xml_desc, args->flags);
-    if (snapshot == NULL)
+    if (!(snapshot = virDomainSnapshotCreateXML(domain, args->xml_desc, args->flags)))
         goto cleanup;
 
     make_nonnull_domain_snapshot(&ret->snap, snapshot);
@@ -8193,17 +7983,14 @@ remoteDispatchDomainSnapshotDumpXml(struct qemud_server *server ATTRIBUTE_UNUSED
         goto cleanup;
     }
 
-    domain = get_nonnull_domain(conn, args->snap.domain);
-    if (domain == NULL)
+    if (!(domain = get_nonnull_domain(conn, args->snap.domain)))
         goto cleanup;
 
-    snapshot = get_nonnull_domain_snapshot(domain, args->snap);
-    if (snapshot == NULL)
+    if (!(snapshot = get_nonnull_domain_snapshot(domain, args->snap)))
         goto cleanup;
 
     /* remoteDispatchClientRequest will free this. */
-    ret->xml = virDomainSnapshotGetXMLDesc(snapshot, args->flags);
-    if (!ret->xml)
+    if (!(ret->xml = virDomainSnapshotGetXMLDesc(snapshot, args->flags)))
         goto cleanup;
 
     rv = 0;
@@ -8235,12 +8022,10 @@ remoteDispatchDomainSnapshotNum(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    domain = get_nonnull_domain(conn, args->domain);
-    if (domain == NULL)
+    if (!(domain = get_nonnull_domain(conn, args->domain)))
         goto cleanup;
 
-    ret->num = virDomainSnapshotNum(domain, args->flags);
-    if (ret->num < 0)
+    if ((ret->num = virDomainSnapshotNum(domain, args->flags)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -8277,8 +8062,7 @@ remoteDispatchDomainSnapshotListNames(struct qemud_server *server ATTRIBUTE_UNUS
         goto cleanup;
     }
 
-    domain = get_nonnull_domain(conn, args->domain);
-    if (domain == NULL)
+    if (!(domain = get_nonnull_domain(conn, args->domain)))
         goto cleanup;
 
     /* Allocate return buffer. */
@@ -8325,12 +8109,10 @@ remoteDispatchDomainSnapshotLookupByName(struct qemud_server *server ATTRIBUTE_U
         goto cleanup;
     }
 
-    domain = get_nonnull_domain(conn, args->domain);
-    if (domain == NULL)
+    if (!(domain = get_nonnull_domain(conn, args->domain)))
         goto cleanup;
 
-    snapshot = virDomainSnapshotLookupByName(domain, args->name, args->flags);
-    if (snapshot == NULL)
+    if (!(snapshot = virDomainSnapshotLookupByName(domain, args->name, args->flags)))
         goto cleanup;
 
     make_nonnull_domain_snapshot(&ret->snap, snapshot);
@@ -8365,8 +8147,7 @@ remoteDispatchDomainHasCurrentSnapshot(struct qemud_server *server ATTRIBUTE_UNU
         goto cleanup;
     }
 
-    domain = get_nonnull_domain(conn, args->domain);
-    if (domain == NULL)
+    if (!(domain = get_nonnull_domain(conn, args->domain)))
         goto cleanup;
 
     result = virDomainHasCurrentSnapshot(domain, args->flags);
@@ -8403,12 +8184,10 @@ remoteDispatchDomainSnapshotCurrent(struct qemud_server *server ATTRIBUTE_UNUSED
         goto cleanup;
     }
 
-    domain = get_nonnull_domain(conn, args->domain);
-    if (domain == NULL)
+    if (!(domain = get_nonnull_domain(conn, args->domain)))
         goto cleanup;
 
-    snapshot = virDomainSnapshotCurrent(domain, args->flags);
-    if (snapshot == NULL)
+    if (!(snapshot = virDomainSnapshotCurrent(domain, args->flags)))
         goto cleanup;
 
     make_nonnull_domain_snapshot(&ret->snap, snapshot);
@@ -8443,12 +8222,10 @@ remoteDispatchDomainRevertToSnapshot(struct qemud_server *server ATTRIBUTE_UNUSE
         goto cleanup;
     }
 
-    domain = get_nonnull_domain(conn, args->snap.domain);
-    if (domain == NULL)
+    if (!(domain = get_nonnull_domain(conn, args->snap.domain)))
         goto cleanup;
 
-    snapshot = get_nonnull_domain_snapshot(domain, args->snap);
-    if (snapshot == NULL)
+    if (!(snapshot = get_nonnull_domain_snapshot(domain, args->snap)))
         goto cleanup;
 
     if (virDomainRevertToSnapshot(snapshot, args->flags) < 0)
@@ -8484,12 +8261,10 @@ remoteDispatchDomainSnapshotDelete(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    domain = get_nonnull_domain(conn, args->snap.domain);
-    if (domain == NULL)
+    if (!(domain = get_nonnull_domain(conn, args->snap.domain)))
         goto cleanup;
 
-    snapshot = get_nonnull_domain_snapshot(domain, args->snap);
-    if (snapshot == NULL)
+    if (!(snapshot = get_nonnull_domain_snapshot(domain, args->snap)))
         goto cleanup;
 
     if (virDomainSnapshotDelete(snapshot, args->flags) < 0)
@@ -8577,8 +8352,7 @@ remoteDispatchDomainEventsDeregisterAny(struct qemud_server *server ATTRIBUTE_UN
         goto cleanup;
     }
 
-    callbackID = client->domainEventCallbackID[args->eventID];
-    if (callbackID < 0) {
+    if ((callbackID = client->domainEventCallbackID[args->eventID]) < 0) {
         virNetError(VIR_ERR_INTERNAL_ERROR, _("domain event %d not registered"), args->eventID);
         goto cleanup;
     }
@@ -8614,8 +8388,7 @@ remoteDispatchNwfilterLookupByName(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    nwfilter = virNWFilterLookupByName(conn, args->name);
-    if (nwfilter == NULL)
+    if (!(nwfilter = virNWFilterLookupByName(conn, args->name)))
         goto cleanup;
 
     make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
@@ -8647,8 +8420,7 @@ remoteDispatchNwfilterLookupByUuid(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    nwfilter = virNWFilterLookupByUUID(conn, (unsigned char *) args->uuid);
-    if (nwfilter == NULL)
+    if (!(nwfilter = virNWFilterLookupByUUID(conn, (unsigned char *) args->uuid)))
         goto cleanup;
 
     make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
@@ -8681,8 +8453,7 @@ remoteDispatchNwfilterDefineXml(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    nwfilter = virNWFilterDefineXML(conn, args->xml);
-    if (nwfilter == NULL)
+    if (!(nwfilter = virNWFilterDefineXML(conn, args->xml)))
         goto cleanup;
 
     make_nonnull_nwfilter(&ret->nwfilter, nwfilter);
@@ -8715,8 +8486,7 @@ remoteDispatchNwfilterUndefine(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
-    if (nwfilter == NULL)
+    if (!(nwfilter = get_nonnull_nwfilter(conn, args->nwfilter)))
         goto cleanup;
 
     if (virNWFilterUndefine(nwfilter) < 0)
@@ -8795,13 +8565,11 @@ remoteDispatchNwfilterGetXmlDesc(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    nwfilter = get_nonnull_nwfilter(conn, args->nwfilter);
-    if (nwfilter == NULL)
+    if (!(nwfilter = get_nonnull_nwfilter(conn, args->nwfilter)))
         goto cleanup;
 
     /* remoteDispatchClientRequest will free this. */
-    ret->xml = virNWFilterGetXMLDesc(nwfilter, args->flags);
-    if (!ret->xml)
+    if (!(ret->xml = virNWFilterGetXMLDesc(nwfilter, args->flags)))
         goto cleanup;
 
     rv = 0;
@@ -8831,8 +8599,7 @@ remoteDispatchNumOfNwfilters(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    ret->num = virConnectNumOfNWFilters(conn);
-    if (ret->num < 0)
+    if ((ret->num = virConnectNumOfNWFilters(conn)) < 0)
         goto cleanup;
 
     rv = 0;
@@ -8862,8 +8629,7 @@ remoteDispatchDomainGetBlockInfo(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->dom);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
     if (virDomainGetBlockInfo(dom, args->path, &info, args->flags) < 0)
@@ -8900,8 +8666,7 @@ qemuDispatchMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    domain = get_nonnull_domain(conn, args->domain);
-    if (domain == NULL)
+    if (!(domain = get_nonnull_domain(conn, args->domain)))
         goto cleanup;
 
     if (virDomainQemuMonitorCommand(domain, args->cmd, &ret->result,
@@ -8928,7 +8693,6 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
                                 remote_domain_open_console_args *args,
                                 void *ret ATTRIBUTE_UNUSED)
 {
-    int r;
     struct qemud_client_stream *stream = NULL;
     virDomainPtr dom = NULL;
     int rv = -1;
@@ -8938,21 +8702,18 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    dom = get_nonnull_domain(conn, args->domain);
-    if (dom == NULL)
+    if (!(dom = get_nonnull_domain(conn, args->domain)))
         goto cleanup;
 
-    stream = remoteCreateClientStream(conn, hdr);
-    if (!stream) {
+    if (!(stream = remoteCreateClientStream(conn, hdr))) {
         virReportOOMError();
         goto cleanup;
     }
 
-    r = virDomainOpenConsole(dom,
+    if (virDomainOpenConsole(dom,
                              args->devname ? *args->devname : NULL,
                              stream->st,
-                             args->flags);
-    if (r < 0)
+                             args->flags) < 0)
         goto cleanup;
 
     if (remoteAddClientStream(client, stream, 1) < 0)
-- 
1.7.4.2




More information about the libvir-list mailing list