lxc: Exit on first error in lxcDomainGetMemoryParameters

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.
This commit is contained in:
Matthias Bolte 2010-11-06 18:52:00 +01:00
parent 9562ca3f92
commit c3697a0ed5

View File

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