]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
lxc: Exit on first error in lxcDomainGetMemoryParameters
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 6 Nov 2010 17:52:00 +0000 (18:52 +0100)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Mon, 8 Nov 2010 20:26:28 +0000 (21:26 +0100)
There is no point in trying to fill params beyond the first error,
because when lxcDomainGetMemoryParameters returns -1 then the caller
cannot detect which values in params are valid.

src/lxc/lxc_driver.c

index d39b60e0afb257cd689387904878e18ef07ed150..f7630dd200db645f2de8fe2789f735dda47d9199 100644 (file)
@@ -823,7 +823,6 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
         goto cleanup;
     }
 
-    ret = 0;
     for (i = 0; i < *nparams; i++) {
         virMemoryParameterPtr param = &params[i];
         val = 0;
@@ -836,14 +835,12 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
             if (rc != 0) {
                 virReportSystemError(-rc, "%s",
                                      _("unable to get memory hard limit"));
-                ret = -1;
-                continue;
+                goto cleanup;
             }
             if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_HARD_LIMIT) == NULL) {
                 lxcError(VIR_ERR_INTERNAL_ERROR,
                          "%s", _("Field memory hard limit too long for destination"));
-                ret = -1;
-                continue;
+                goto cleanup;
             }
             param->value.ul = val;
             break;
@@ -853,14 +850,12 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
             if (rc != 0) {
                 virReportSystemError(-rc, "%s",
                                      _("unable to get memory soft limit"));
-                ret = -1;
-                continue;
+                goto cleanup;
             }
             if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_SOFT_LIMIT) == NULL) {
                 lxcError(VIR_ERR_INTERNAL_ERROR,
                          "%s", _("Field memory soft limit too long for destination"));
-                ret = -1;
-                continue;
+                goto cleanup;
             }
             param->value.ul = val;
             break;
@@ -870,14 +865,12 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
             if (rc != 0) {
                 virReportSystemError(-rc, "%s",
                                      _("unable to get swap hard limit"));
-                ret = -1;
-                continue;
+                goto cleanup;
             }
             if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT) == NULL) {
                 lxcError(VIR_ERR_INTERNAL_ERROR,
                          "%s", _("Field swap hard limit too long for destination"));
-                ret = -1;
-                continue;
+                goto cleanup;
             }
             param->value.ul = val;
             break;
@@ -888,6 +881,8 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
         }
     }
 
+    ret = 0;
+
 cleanup:
     if (cgroup)
         virCgroupFree(&cgroup);