[PATCH v1 04/37] Adapt to VIR_ALLOC and virAsprintf in daemon/*

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

 



---
 daemon/libvirtd-config.c |  12 +--
 daemon/libvirtd.c        |  24 ++---
 daemon/remote.c          | 234 ++++++++++++-----------------------------------
 daemon/stream.c          |   4 +-
 4 files changed, 70 insertions(+), 204 deletions(-)

diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
index 017d470..a3cc56f 100644
--- a/daemon/libvirtd-config.c
+++ b/daemon/libvirtd-config.c
@@ -200,15 +200,13 @@ daemonConfigFilePath(bool privileged, char **configfile)
 
         if (virAsprintf(configfile, "%s/libvirtd.conf", configdir) < 0) {
             VIR_FREE(configdir);
-            goto no_memory;
+            goto error;
         }
         VIR_FREE(configdir);
     }
 
     return 0;
 
-no_memory:
-    virReportOOMError();
 error:
     return -1;
 }
@@ -220,10 +218,8 @@ daemonConfigNew(bool privileged ATTRIBUTE_UNUSED)
     char *localhost;
     int ret;
 
-    if (VIR_ALLOC(data) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC(data) < 0)
         return NULL;
-    }
 
     data->listen_tls = 1;
     data->listen_tcp = 0;
@@ -294,12 +290,10 @@ daemonConfigNew(bool privileged ATTRIBUTE_UNUSED)
     }
     VIR_FREE(localhost);
     if (ret < 0)
-        goto no_memory;
+        goto error;
 
     return data;
 
-no_memory:
-    virReportOOMError();
 error:
     daemonConfigFree(data);
     return NULL;
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 3db4f1c..9f7fd8a 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -263,7 +263,7 @@ daemonPidFilePath(bool privileged,
 
         if (virAsprintf(pidfile, "%s/libvirtd.pid", rundir) < 0) {
             VIR_FREE(rundir);
-            goto no_memory;
+            goto error;
         }
 
         VIR_FREE(rundir);
@@ -271,8 +271,6 @@ daemonPidFilePath(bool privileged,
 
     return 0;
 
-no_memory:
-    virReportOOMError();
 error:
     return -1;
 }
@@ -285,10 +283,10 @@ daemonUnixSocketPaths(struct daemonConfig *config,
 {
     if (config->unix_sock_dir) {
         if (virAsprintf(sockfile, "%s/libvirt-sock", config->unix_sock_dir) < 0)
-            goto no_memory;
+            goto error;
         if (privileged &&
             virAsprintf(rosockfile, "%s/libvirt-sock-ro", config->unix_sock_dir) < 0)
-            goto no_memory;
+            goto error;
     } else {
         if (privileged) {
             if (VIR_STRDUP(*sockfile, LOCALSTATEDIR "/run/libvirt/libvirt-sock") < 0 ||
@@ -310,7 +308,7 @@ daemonUnixSocketPaths(struct daemonConfig *config,
 
             if (virAsprintf(sockfile, "%s/libvirt-sock", rundir) < 0) {
                 VIR_FREE(rundir);
-                goto no_memory;
+                goto error;
             }
 
             VIR_FREE(rundir);
@@ -318,8 +316,6 @@ daemonUnixSocketPaths(struct daemonConfig *config,
     }
     return 0;
 
-no_memory:
-    virReportOOMError();
 error:
     return -1;
 }
@@ -666,7 +662,7 @@ daemonSetupLogging(struct daemonConfig *config,
         char *tmp;
         if (access("/run/systemd/journal/socket", W_OK) >= 0) {
             if (virAsprintf(&tmp, "%d:journald", virLogGetDefaultPriority()) < 0)
-                goto no_memory;
+                goto error;
             virLogParseOutputs(tmp);
             VIR_FREE(tmp);
         }
@@ -684,7 +680,7 @@ daemonSetupLogging(struct daemonConfig *config,
                 if (virAsprintf(&tmp, "%d:file:%s/log/libvirt/libvirtd.log",
                                 virLogGetDefaultPriority(),
                                 LOCALSTATEDIR) == -1)
-                    goto no_memory;
+                    goto error;
             } else {
                 char *logdir = virGetUserCacheDirectory();
                 mode_t old_umask;
@@ -702,13 +698,13 @@ daemonSetupLogging(struct daemonConfig *config,
                 if (virAsprintf(&tmp, "%d:file:%s/libvirtd.log",
                                 virLogGetDefaultPriority(), logdir) == -1) {
                     VIR_FREE(logdir);
-                    goto no_memory;
+                    goto error;
                 }
                 VIR_FREE(logdir);
             }
         } else {
             if (virAsprintf(&tmp, "%d:stderr", virLogGetDefaultPriority()) < 0)
-                goto no_memory;
+                goto error;
         }
         virLogParseOutputs(tmp);
         VIR_FREE(tmp);
@@ -722,8 +718,6 @@ daemonSetupLogging(struct daemonConfig *config,
 
     return 0;
 
-no_memory:
-    virReportOOMError();
 error:
     return -1;
 }
@@ -1153,7 +1147,7 @@ int main(int argc, char **argv) {
         }
         *tmp = '\0';
         char *driverdir;
-        if (virAsprintf(&driverdir, "%s/../../src/.libs", argv[0]) < 0) {
+        if (virAsprintfQuiet(&driverdir, "%s/../../src/.libs", argv[0]) < 0) {
             fprintf(stderr, _("%s: initialization failed\n"), argv[0]);
             exit(EXIT_FAILURE);
         }
diff --git a/daemon/remote.c b/daemon/remote.c
index cb362da..a465d4e 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -332,10 +332,8 @@ static int remoteRelayDomainEventGraphics(virConnectPtr conn ATTRIBUTE_UNUSED,
         goto error;
 
     data.subject.subject_len = subject->nidentity;
-    if (VIR_ALLOC_N(data.subject.subject_val, data.subject.subject_len) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC_N(data.subject.subject_val, data.subject.subject_len) < 0)
         goto error;
-    }
 
     for (i = 0; i < data.subject.subject_len; i++) {
         if (VIR_STRDUP(data.subject.subject_val[i].type, subject->identities[i].type) < 0 ||
@@ -448,12 +446,12 @@ static int remoteRelayDomainEventDiskChange(virConnectPtr conn ATTRIBUTE_UNUSED,
     if (oldSrcPath &&
         ((VIR_ALLOC(oldSrcPath_p) < 0) ||
          VIR_STRDUP(*oldSrcPath_p, oldSrcPath) < 0))
-        goto mem_error;
+        goto error;
 
     if (newSrcPath &&
         ((VIR_ALLOC(newSrcPath_p) < 0) ||
          VIR_STRDUP(*newSrcPath_p, newSrcPath) < 0))
-        goto mem_error;
+        goto error;
 
     data.oldSrcPath = oldSrcPath_p;
     data.newSrcPath = newSrcPath_p;
@@ -469,8 +467,6 @@ static int remoteRelayDomainEventDiskChange(virConnectPtr conn ATTRIBUTE_UNUSED,
 
     return 0;
 
-mem_error:
-    virReportOOMError();
 error:
     VIR_FREE(oldSrcPath_p);
     VIR_FREE(newSrcPath_p);
@@ -670,14 +666,12 @@ void *remoteClientInitHook(virNetServerClientPtr client,
     struct daemonClientPrivate *priv;
     int i;
 
-    if (VIR_ALLOC(priv) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC(priv) < 0)
         return NULL;
-    }
 
     if (virMutexInit(&priv->lock) < 0) {
         VIR_FREE(priv);
-        virReportOOMError();
+        virReportSystemError(errno, "%s", _("unable to init mutex"));
         return NULL;
     }
 
@@ -807,10 +801,8 @@ remoteSerializeTypedParameters(virTypedParameterPtr params,
     remote_typed_param *val;
 
     *ret_params_len = nparams;
-    if (VIR_ALLOC_N(val, nparams) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC_N(val, nparams) < 0)
         goto cleanup;
-    }
 
     for (i = 0, j = 0; i < nparams; ++i) {
         /* virDomainGetCPUStats can return a sparse array; also, we
@@ -889,10 +881,8 @@ remoteDeserializeTypedParameters(remote_typed_param *args_params_val,
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
         goto cleanup;
     }
-    if (VIR_ALLOC_N(params, args_params_len) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC_N(params, args_params_len) < 0)
         goto cleanup;
-    }
 
     *nparams = args_params_len;
 
@@ -978,7 +968,7 @@ remoteDispatchDomainGetSchedulerParameters(virNetServerPtr server ATTRIBUTE_UNUS
         goto cleanup;
     }
     if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0)
-        goto no_memory;
+        goto cleanup;
     nparams = args->nparams;
 
     if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
@@ -1002,10 +992,6 @@ cleanup:
     if (dom)
         virDomainFree(dom);
     return rv;
-
-no_memory:
-    virReportOOMError();
-    goto cleanup;
 }
 
 static int
@@ -1033,10 +1019,8 @@ remoteDispatchConnectListAllDomains(virNetServerPtr server ATTRIBUTE_UNUSED,
         goto cleanup;
 
     if (doms && ndomains) {
-        if (VIR_ALLOC_N(ret->domains.domains_val, ndomains) < 0) {
-            virReportOOMError();
+        if (VIR_ALLOC_N(ret->domains.domains_val, ndomains) < 0)
             goto cleanup;
-        }
 
         ret->domains.domains_len = ndomains;
 
@@ -1087,7 +1071,7 @@ remoteDispatchDomainGetSchedulerParametersFlags(virNetServerPtr server ATTRIBUTE
         goto cleanup;
     }
     if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0)
-        goto no_memory;
+        goto cleanup;
     nparams = args->nparams;
 
     if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
@@ -1112,10 +1096,6 @@ cleanup:
     if (dom)
         virDomainFree(dom);
     return rv;
-
-no_memory:
-    virReportOOMError();
-    goto cleanup;
 }
 
 static int
@@ -1148,20 +1128,16 @@ remoteDispatchDomainMemoryStats(virNetServerPtr server ATTRIBUTE_UNUSED,
         goto cleanup;
 
     /* Allocate stats array for making dispatch call */
-    if (VIR_ALLOC_N(stats, args->maxStats) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC_N(stats, args->maxStats) < 0)
         goto cleanup;
-    }
 
     nr_stats = virDomainMemoryStats(dom, stats, args->maxStats, args->flags);
     if (nr_stats < 0)
         goto cleanup;
 
     /* Allocate return buffer */
-    if (VIR_ALLOC_N(ret->stats.stats_val, args->maxStats) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC_N(ret->stats.stats_val, args->maxStats) < 0)
         goto cleanup;
-    }
 
     /* Copy the stats into the xdr return structure */
     for (i = 0; i < nr_stats; i++) {
@@ -1216,10 +1192,8 @@ remoteDispatchDomainBlockPeek(virNetServerPtr server ATTRIBUTE_UNUSED,
     }
 
     ret->buffer.buffer_len = size;
-    if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0)
         goto cleanup;
-    }
 
     if (virDomainBlockPeek(dom, path, offset, size,
                            ret->buffer.buffer_val, flags) < 0)
@@ -1267,10 +1241,8 @@ remoteDispatchDomainBlockStatsFlags(virNetServerPtr server ATTRIBUTE_UNUSED,
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
         goto cleanup;
     }
-    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) {
-        virReportOOMError();
+    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0)
         goto cleanup;
-    }
     nparams = args->nparams;
 
     if (virDomainBlockStatsFlags(dom, path, params, &nparams, flags) < 0)
@@ -1337,10 +1309,8 @@ remoteDispatchDomainMemoryPeek(virNetServerPtr server ATTRIBUTE_UNUSED,
     }
 
     ret->buffer.buffer_len = size;
-    if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0)
         goto cleanup;
-    }
 
     if (virDomainMemoryPeek(dom, offset, size,
                             ret->buffer.buffer_val, flags) < 0)
@@ -1380,19 +1350,15 @@ remoteDispatchDomainGetSecurityLabel(virNetServerPtr server ATTRIBUTE_UNUSED,
     if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
         goto cleanup;
 
-    if (VIR_ALLOC(seclabel) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC(seclabel) < 0)
         goto cleanup;
-    }
 
     if (virDomainGetSecurityLabel(dom, seclabel) < 0)
         goto cleanup;
 
     ret->label.label_len = strlen(seclabel->label) + 1;
-    if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0)
         goto cleanup;
-    }
     strcpy(ret->label.label_val, seclabel->label);
     ret->enforcing = seclabel->enforcing;
 
@@ -1436,18 +1402,14 @@ remoteDispatchDomainGetSecurityLabelList(virNetServerPtr server ATTRIBUTE_UNUSED
         goto done;
     }
 
-    if (VIR_ALLOC_N(ret->labels.labels_val, len) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC_N(ret->labels.labels_val, len) < 0)
         goto cleanup;
-    }
 
     for (i = 0; i < len; i++) {
         size_t label_len = strlen(seclabels[i].label) + 1;
         remote_domain_get_security_label_ret *cur = &ret->labels.labels_val[i];
-        if (VIR_ALLOC_N(cur->label.label_val, label_len) < 0) {
-            virReportOOMError();
+        if (VIR_ALLOC_N(cur->label.label_val, label_len) < 0)
             goto cleanup;
-        }
         if (virStrcpy(cur->label.label_val, seclabels[i].label, label_len) == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("failed to copy security label"));
@@ -1492,17 +1454,13 @@ remoteDispatchNodeGetSecurityModel(virNetServerPtr server ATTRIBUTE_UNUSED,
         goto cleanup;
 
     ret->model.model_len = strlen(secmodel.model) + 1;
-    if (VIR_ALLOC_N(ret->model.model_val, ret->model.model_len) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC_N(ret->model.model_val, ret->model.model_len) < 0)
         goto cleanup;
-    }
     strcpy(ret->model.model_val, secmodel.model);
 
     ret->doi.doi_len = strlen(secmodel.doi) + 1;
-    if (VIR_ALLOC_N(ret->doi.doi_val, ret->doi.doi_len) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC_N(ret->doi.doi_val, ret->doi.doi_len) < 0)
         goto cleanup;
-    }
     strcpy(ret->doi.doi_val, secmodel.doi);
 
     rv = 0;
@@ -1550,7 +1508,7 @@ remoteDispatchDomainGetVcpuPinInfo(virNetServerPtr server ATTRIBUTE_UNUSED,
     /* Allocate buffers to take the results. */
     if (args->maplen > 0 &&
         VIR_ALLOC_N(cpumaps, args->ncpumaps * args->maplen) < 0)
-        goto no_memory;
+        goto cleanup;
 
     if ((num = virDomainGetVcpuPinInfo(dom,
                                        args->ncpumaps,
@@ -1577,10 +1535,6 @@ cleanup:
     if (dom)
         virDomainFree(dom);
     return rv;
-
-no_memory:
-    virReportOOMError();
-    goto cleanup;
 }
 
 static int
@@ -1646,7 +1600,7 @@ remoteDispatchDomainGetEmulatorPinInfo(virNetServerPtr server ATTRIBUTE_UNUSED,
     /* Allocate buffers to take the results */
     if (args->maplen > 0 &&
         VIR_ALLOC_N(cpumaps, args->maplen) < 0)
-        goto no_memory;
+        goto cleanup;
 
     if ((r = virDomainGetEmulatorPinInfo(dom,
                                          cpumaps,
@@ -1668,10 +1622,6 @@ cleanup:
     if (dom)
         virDomainFree(dom);
     return rv;
-
-no_memory:
-    virReportOOMError();
-    goto cleanup;
 }
 
 static int
@@ -1711,10 +1661,10 @@ remoteDispatchDomainGetVcpus(virNetServerPtr server ATTRIBUTE_UNUSED,
 
     /* Allocate buffers to take the results. */
     if (VIR_ALLOC_N(info, args->maxinfo) < 0)
-        goto no_memory;
+        goto cleanup;
     if (args->maplen > 0 &&
         VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0)
-        goto no_memory;
+        goto cleanup;
 
     if ((info_len = virDomainGetVcpus(dom,
                                       info, args->maxinfo,
@@ -1724,7 +1674,7 @@ remoteDispatchDomainGetVcpus(virNetServerPtr server ATTRIBUTE_UNUSED,
     /* Allocate the return buffer for info. */
     ret->info.info_len = info_len;
     if (VIR_ALLOC_N(ret->info.info_val, info_len) < 0)
-        goto no_memory;
+        goto cleanup;
 
     for (i = 0; i < info_len; ++i) {
         ret->info.info_val[i].number = info[i].number;
@@ -1753,10 +1703,6 @@ cleanup:
     if (dom)
         virDomainFree(dom);
     return rv;
-
-no_memory:
-    virReportOOMError();
-    goto cleanup;
 }
 
 static int
@@ -1785,10 +1731,8 @@ remoteDispatchDomainMigratePrepare(virNetServerPtr server ATTRIBUTE_UNUSED,
     dname = args->dname == NULL ? NULL : *args->dname;
 
     /* Wacky world of XDR ... */
-    if (VIR_ALLOC(uri_out) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC(uri_out) < 0)
         goto cleanup;
-    }
 
     if (virDomainMigratePrepare(priv->conn, &cookie, &cookielen,
                                 uri_in, uri_out,
@@ -1842,10 +1786,8 @@ remoteDispatchDomainMigratePrepare2(virNetServerPtr server ATTRIBUTE_UNUSED,
     dname = args->dname == NULL ? NULL : *args->dname;
 
     /* Wacky world of XDR ... */
-    if (VIR_ALLOC(uri_out) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC(uri_out) < 0)
         goto cleanup;
-    }
 
     if (virDomainMigratePrepare2(priv->conn, &cookie, &cookielen,
                                  uri_in, uri_out,
@@ -1895,10 +1837,8 @@ remoteDispatchDomainGetMemoryParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
         goto cleanup;
     }
-    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) {
-        virReportOOMError();
+    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0)
         goto cleanup;
-    }
     nparams = args->nparams;
 
     if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
@@ -1960,10 +1900,8 @@ remoteDispatchDomainGetNumaParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
         goto cleanup;
     }
-    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) {
-        virReportOOMError();
+    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0)
         goto cleanup;
-    }
     nparams = args->nparams;
 
     if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
@@ -2025,10 +1963,8 @@ remoteDispatchDomainGetBlkioParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
         goto cleanup;
     }
-    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) {
-        virReportOOMError();
+    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0)
         goto cleanup;
-    }
     nparams = args->nparams;
 
     if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
@@ -2091,10 +2027,8 @@ remoteDispatchNodeGetCPUStats(virNetServerPtr server ATTRIBUTE_UNUSED,
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
         goto cleanup;
     }
-    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) {
-        virReportOOMError();
+    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0)
         goto cleanup;
-    }
     nparams = args->nparams;
 
     if (virNodeGetCPUStats(priv->conn, cpuNum, params, &nparams, flags) < 0)
@@ -2111,7 +2045,7 @@ remoteDispatchNodeGetCPUStats(virNetServerPtr server ATTRIBUTE_UNUSED,
     /* Serialise the memory parameters. */
     ret->params.params_len = nparams;
     if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
-        goto no_memory;
+        goto cleanup;
 
     for (i = 0; i < nparams; ++i) {
         /* remoteDispatchClientRequest will free this: */
@@ -2135,10 +2069,6 @@ cleanup:
     }
     VIR_FREE(params);
     return rv;
-
-no_memory:
-    virReportOOMError();
-    goto cleanup;
 }
 
 static int
@@ -2169,10 +2099,8 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr server ATTRIBUTE_UNUSED,
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
         goto cleanup;
     }
-    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) {
-        virReportOOMError();
+    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0)
         goto cleanup;
-    }
     nparams = args->nparams;
 
     if (virNodeGetMemoryStats(priv->conn, cellNum, params, &nparams, flags) < 0)
@@ -2189,7 +2117,7 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr server ATTRIBUTE_UNUSED,
     /* Serialise the memory parameters. */
     ret->params.params_len = nparams;
     if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
-        goto no_memory;
+        goto cleanup;
 
     for (i = 0; i < nparams; ++i) {
         /* remoteDispatchClientRequest will free this: */
@@ -2213,10 +2141,6 @@ cleanup:
     }
     VIR_FREE(params);
     return rv;
-
-no_memory:
-    virReportOOMError();
-    goto cleanup;
 }
 
 static int
@@ -2285,10 +2209,8 @@ remoteDispatchDomainGetBlockIoTune(virNetServerPtr server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) {
-        virReportOOMError();
+    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0)
         goto cleanup;
-    }
     nparams = args->nparams;
 
     if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
@@ -2354,10 +2276,8 @@ remoteDispatchAuthList(virNetServerPtr server ATTRIBUTE_UNUSED,
         } else if (callerUid == 0) {
             char *ident;
             if (virAsprintf(&ident, "pid:%lld,uid:%d",
-                            (long long) callerPid, (int) callerUid) < 0) {
-                virReportOOMError();
+                            (long long) callerPid, (int) callerUid) < 0)
                 goto cleanup;
-            }
             VIR_INFO("Bypass polkit auth for privileged client %s", ident);
             virNetServerClientSetAuth(client, 0);
             auth = VIR_NET_SERVER_SERVICE_AUTH_NONE;
@@ -2366,10 +2286,8 @@ remoteDispatchAuthList(virNetServerPtr server ATTRIBUTE_UNUSED,
     }
 
     ret->types.types_len = 1;
-    if (VIR_ALLOC_N(ret->types.types_val, ret->types.types_len) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC_N(ret->types.types_val, ret->types.types_len) < 0)
         goto cleanup;
-    }
 
     switch (auth) {
     case VIR_NET_SERVER_SERVICE_AUTH_NONE:
@@ -2815,10 +2733,8 @@ remoteDispatchAuthPolkit(virNetServerPtr server ATTRIBUTE_UNUSED,
     virCommandAddArg(cmd, "--allow-user-interaction");
 
     if (virAsprintf(&ident, "pid:%lld,uid:%d",
-                    (long long) callerPid, callerUid) < 0) {
-        virReportOOMError();
+                    (long long) callerPid, callerUid) < 0)
         goto authfail;
-    }
 
     if (virCommandRun(cmd, &status) < 0)
         goto authfail;
@@ -2920,10 +2836,8 @@ remoteDispatchAuthPolkit(virNetServerPtr server ATTRIBUTE_UNUSED,
     }
 
     if (virAsprintf(&ident, "pid:%lld,uid:%d",
-                    (long long) callerPid, callerUid) < 0) {
-        virReportOOMError();
+                    (long long) callerPid, callerUid) < 0)
         goto authfail;
-    }
 
     if (!(sysbus = virDBusGetSystemBus()))
         goto authfail;
@@ -3073,10 +2987,8 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr server ATTRIBUTE_UNUSED,
     } else {
         /* remoteDispatchClientRequest will free this. */
         char **parent_p;
-        if (VIR_ALLOC(parent_p) < 0) {
-            virReportOOMError();
+        if (VIR_ALLOC(parent_p) < 0)
             goto cleanup;
-        }
         if (VIR_STRDUP(*parent_p, parent) < 0) {
             VIR_FREE(parent_p);
             goto cleanup;
@@ -3495,10 +3407,8 @@ remoteDispatchDomainMigratePrepare3(virNetServerPtr server ATTRIBUTE_UNUSED,
     dname = args->dname == NULL ? NULL : *args->dname;
 
     /* Wacky world of XDR ... */
-    if (VIR_ALLOC(uri_out) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC(uri_out) < 0)
         goto cleanup;
-    }
 
     if (virDomainMigratePrepare3(priv->conn,
                                  args->cookie_in.cookie_in_val,
@@ -3792,10 +3702,8 @@ remoteDispatchDomainGetInterfaceParameters(virNetServerPtr server ATTRIBUTE_UNUS
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
         goto cleanup;
     }
-    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) {
-        virReportOOMError();
+    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0)
         goto cleanup;
-    }
     nparams = args->nparams;
 
     if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
@@ -3860,10 +3768,8 @@ remoteDispatchDomainGetCPUStats(virNetServerPtr server ATTRIBUTE_UNUSED,
     }
 
     if (args->nparams > 0 &&
-        VIR_ALLOC_N(params, args->ncpus * args->nparams) < 0) {
-        virReportOOMError();
+        VIR_ALLOC_N(params, args->ncpus * args->nparams) < 0)
         goto cleanup;
-    }
 
     if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
         goto cleanup;
@@ -3934,10 +3840,8 @@ static int remoteDispatchDomainGetDiskErrors(
     }
 
     if (args->maxerrors &&
-        VIR_ALLOC_N(errors, args->maxerrors) < 0) {
-        virReportOOMError();
+        VIR_ALLOC_N(errors, args->maxerrors) < 0)
         goto cleanup;
-    }
 
     if ((len = virDomainGetDiskErrors(dom, errors,
                                       args->maxerrors,
@@ -3996,10 +3900,8 @@ remoteDispatchDomainListAllSnapshots(virNetServerPtr server ATTRIBUTE_UNUSED,
         goto cleanup;
 
     if (snaps && nsnaps) {
-        if (VIR_ALLOC_N(ret->snapshots.snapshots_val, nsnaps) < 0) {
-            virReportOOMError();
+        if (VIR_ALLOC_N(ret->snapshots.snapshots_val, nsnaps) < 0)
             goto cleanup;
-        }
 
         ret->snapshots.snapshots_len = nsnaps;
 
@@ -4060,10 +3962,8 @@ remoteDispatchDomainSnapshotListAllChildren(virNetServerPtr server ATTRIBUTE_UNU
         goto cleanup;
 
     if (snaps && nsnaps) {
-        if (VIR_ALLOC_N(ret->snapshots.snapshots_val, nsnaps) < 0) {
-            virReportOOMError();
+        if (VIR_ALLOC_N(ret->snapshots.snapshots_val, nsnaps) < 0)
             goto cleanup;
-        }
 
         ret->snapshots.snapshots_len = nsnaps;
 
@@ -4118,10 +4018,8 @@ remoteDispatchConnectListAllStoragePools(virNetServerPtr server ATTRIBUTE_UNUSED
         goto cleanup;
 
     if (pools && npools) {
-        if (VIR_ALLOC_N(ret->pools.pools_val, npools) < 0) {
-            virReportOOMError();
+        if (VIR_ALLOC_N(ret->pools.pools_val, npools) < 0)
             goto cleanup;
-        }
 
         ret->pools.pools_len = npools;
 
@@ -4176,10 +4074,8 @@ remoteDispatchStoragePoolListAllVolumes(virNetServerPtr server ATTRIBUTE_UNUSED,
         goto cleanup;
 
     if (vols && nvols) {
-        if (VIR_ALLOC_N(ret->vols.vols_val, nvols) < 0) {
-            virReportOOMError();
+        if (VIR_ALLOC_N(ret->vols.vols_val, nvols) < 0)
             goto cleanup;
-        }
 
         ret->vols.vols_len = nvols;
 
@@ -4232,10 +4128,8 @@ remoteDispatchConnectListAllNetworks(virNetServerPtr server ATTRIBUTE_UNUSED,
         goto cleanup;
 
     if (nets && nnets) {
-        if (VIR_ALLOC_N(ret->nets.nets_val, nnets) < 0) {
-            virReportOOMError();
+        if (VIR_ALLOC_N(ret->nets.nets_val, nnets) < 0)
             goto cleanup;
-        }
 
         ret->nets.nets_len = nnets;
 
@@ -4286,10 +4180,8 @@ remoteDispatchConnectListAllInterfaces(virNetServerPtr server ATTRIBUTE_UNUSED,
         goto cleanup;
 
     if (ifaces && nifaces) {
-        if (VIR_ALLOC_N(ret->ifaces.ifaces_val, nifaces) < 0) {
-            virReportOOMError();
+        if (VIR_ALLOC_N(ret->ifaces.ifaces_val, nifaces) < 0)
             goto cleanup;
-        }
 
         ret->ifaces.ifaces_len = nifaces;
 
@@ -4340,10 +4232,8 @@ remoteDispatchConnectListAllNodeDevices(virNetServerPtr server ATTRIBUTE_UNUSED,
         goto cleanup;
 
     if (devices && ndevices) {
-        if (VIR_ALLOC_N(ret->devices.devices_val, ndevices) < 0) {
-            virReportOOMError();
+        if (VIR_ALLOC_N(ret->devices.devices_val, ndevices) < 0)
             goto cleanup;
-        }
 
         ret->devices.devices_len = ndevices;
 
@@ -4394,10 +4284,8 @@ remoteDispatchConnectListAllNWFilters(virNetServerPtr server ATTRIBUTE_UNUSED,
         goto cleanup;
 
     if (filters && nfilters) {
-        if (VIR_ALLOC_N(ret->filters.filters_val, nfilters) < 0) {
-            virReportOOMError();
+        if (VIR_ALLOC_N(ret->filters.filters_val, nfilters) < 0)
             goto cleanup;
-        }
 
         ret->filters.filters_len = nfilters;
 
@@ -4448,10 +4336,8 @@ remoteDispatchConnectListAllSecrets(virNetServerPtr server ATTRIBUTE_UNUSED,
         goto cleanup;
 
     if (secrets && nsecrets) {
-        if (VIR_ALLOC_N(ret->secrets.secrets_val, nsecrets) < 0) {
-            virReportOOMError();
+        if (VIR_ALLOC_N(ret->secrets.secrets_val, nsecrets) < 0)
             goto cleanup;
-        }
 
         ret->secrets.secrets_len = nsecrets;
 
@@ -4503,10 +4389,8 @@ remoteDispatchNodeGetMemoryParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
         goto cleanup;
     }
-    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) {
-        virReportOOMError();
+    if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0)
         goto cleanup;
-    }
     nparams = args->nparams;
 
     if (virNodeGetMemoryParameters(priv->conn, params, &nparams, flags) < 0)
@@ -4758,10 +4642,8 @@ remoteDispatchDomainMigratePrepare3Params(
         goto cleanup;
 
     /* Wacky world of XDR ... */
-    if (VIR_ALLOC(uri_out) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC(uri_out) < 0)
         goto cleanup;
-    }
 
     if (virDomainMigratePrepare3Params(priv->conn, params, nparams,
                                        args->cookie_in.cookie_in_val,
@@ -5148,10 +5030,8 @@ remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr errors,
     remote_domain_disk_error *val = NULL;
     int i = 0;
 
-    if (VIR_ALLOC_N(val, nerrors) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC_N(val, nerrors) < 0)
         goto error;
-    }
 
     for (i = 0; i < nerrors; i++) {
         if (VIR_STRDUP(val[i].disk, errors[i].disk) < 0)
diff --git a/daemon/stream.c b/daemon/stream.c
index 0fb5c85..87dfaf5 100644
--- a/daemon/stream.c
+++ b/daemon/stream.c
@@ -325,10 +325,8 @@ daemonCreateClientStream(virNetServerClientPtr client,
     VIR_DEBUG("client=%p, proc=%d, serial=%d, st=%p",
               client, header->proc, header->serial, st);
 
-    if (VIR_ALLOC(stream) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC(stream) < 0)
         return NULL;
-    }
 
     stream->refs = 1;
     stream->priv = priv;
-- 
1.8.1.5

--
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]