mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-23 20:02:21 +00:00
Simplify virDomainParseMemory
Do not store the return value of virDomainParseScaledValue, it was overwritten anyway. Delete the cleanup label, there is nothing to clean up.
This commit is contained in:
parent
598927a5bc
commit
e1d7273f24
@ -7584,28 +7584,22 @@ virDomainParseMemory(const char *xpath,
|
|||||||
bool required,
|
bool required,
|
||||||
bool capped)
|
bool capped)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
unsigned long long bytes, max;
|
unsigned long long bytes, max;
|
||||||
|
|
||||||
max = virMemoryMaxValue(capped);
|
max = virMemoryMaxValue(capped);
|
||||||
|
|
||||||
ret = virDomainParseScaledValue(xpath, units_xpath, ctxt,
|
if (virDomainParseScaledValue(xpath, units_xpath, ctxt,
|
||||||
&bytes, 1024, max, required);
|
&bytes, 1024, max, required) < 0)
|
||||||
if (ret < 0)
|
return -1;
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/* Yes, we really do use kibibytes for our internal sizing. */
|
/* Yes, we really do use kibibytes for our internal sizing. */
|
||||||
*mem = VIR_DIV_UP(bytes, 1024);
|
*mem = VIR_DIV_UP(bytes, 1024);
|
||||||
|
|
||||||
if (*mem >= VIR_DIV_UP(max, 1024)) {
|
if (*mem >= VIR_DIV_UP(max, 1024)) {
|
||||||
virReportError(VIR_ERR_OVERFLOW, "%s", _("size value too large"));
|
virReportError(VIR_ERR_OVERFLOW, "%s", _("size value too large"));
|
||||||
ret = -1;
|
return -1;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
ret = 0;
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user