提交 50e9b389 编写于 作者: M Michal Privoznik

qemu: Clenup qemuDomainSetInterfaceParameters

which contained some useless lines, copied code, NULL
dereference.
上级 bb311b34
...@@ -7226,8 +7226,8 @@ error: ...@@ -7226,8 +7226,8 @@ error:
* *
* Change a subset or all parameters of interface; currently this * Change a subset or all parameters of interface; currently this
* includes bandwidth parameters. The value of @flags should be * includes bandwidth parameters. The value of @flags should be
* either VIR_DOMAIN_AFFECT_CURRENT, or a bitwise-or of values from * either VIR_DOMAIN_AFFECT_CURRENT, or a bitwise-or of values
* VIR_DOMAIN_AFFECT_LIVE and VIR_DOMAIN_AFFECT_CURRENT, although * VIR_DOMAIN_AFFECT_LIVE and VIR_DOMAIN_AFFECT_CONFIG, although
* hypervisors vary in which flags are supported. * hypervisors vary in which flags are supported.
* *
* This function may require privileged access to the hypervisor. * This function may require privileged access to the hypervisor.
......
...@@ -7779,20 +7779,12 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, ...@@ -7779,20 +7779,12 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
} }
} }
if (VIR_ALLOC(bandwidth) < 0) { if ((VIR_ALLOC(bandwidth) < 0) ||
(VIR_ALLOC(bandwidth->in) < 0) ||
(VIR_ALLOC(bandwidth->out) < 0)) {
virReportOOMError(); virReportOOMError();
goto cleanup; goto cleanup;
} }
if (VIR_ALLOC(bandwidth->in) < 0) {
virReportOOMError();
goto cleanup;
}
memset(bandwidth->in, 0, sizeof(*bandwidth->in));
if (VIR_ALLOC(bandwidth->out) < 0) {
virReportOOMError();
goto cleanup;
}
memset(bandwidth->out, 0, sizeof(*bandwidth->out));
for (i = 0; i < nparams; i++) { for (i = 0; i < nparams; i++) {
virTypedParameterPtr param = &params[i]; virTypedParameterPtr param = &params[i];
...@@ -7817,11 +7809,9 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, ...@@ -7817,11 +7809,9 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
* inbound/outbound to not be set. */ * inbound/outbound to not be set. */
if (!bandwidth->in->average) { if (!bandwidth->in->average) {
VIR_FREE(bandwidth->in); VIR_FREE(bandwidth->in);
bandwidth->in = NULL;
} }
if (!bandwidth->out->average) { if (!bandwidth->out->average) {
VIR_FREE(bandwidth->out); VIR_FREE(bandwidth->out);
bandwidth->out = NULL;
} }
if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (flags & VIR_DOMAIN_AFFECT_LIVE) {
...@@ -7833,28 +7823,26 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, ...@@ -7833,28 +7823,26 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
/* virNetDevBandwidthSet() will clear any previous value of /* virNetDevBandwidthSet() will clear any previous value of
* bandwidth parameters, so merge with old bandwidth parameters * bandwidth parameters, so merge with old bandwidth parameters
* here to prevent them from being lost. */ * here to prevent them from being lost. */
if (bandwidth->in || net->bandwidth->in) { if (bandwidth->in ||
(net->bandwidth && net->bandwidth->in)) {
if (VIR_ALLOC(newBandwidth->in) < 0) { if (VIR_ALLOC(newBandwidth->in) < 0) {
virReportOOMError(); virReportOOMError();
goto cleanup; goto cleanup;
} }
if (bandwidth->in)
memcpy(newBandwidth->in, bandwidth->in, memcpy(newBandwidth->in,
sizeof(*newBandwidth->in)); bandwidth->in ? bandwidth->in : net->bandwidth->in,
else if (net->bandwidth->in)
memcpy(newBandwidth->in, net->bandwidth->in,
sizeof(*newBandwidth->in)); sizeof(*newBandwidth->in));
} }
if (bandwidth->out || net->bandwidth->out) { if (bandwidth->out ||
(net->bandwidth && net->bandwidth->out)) {
if (VIR_ALLOC(newBandwidth->out) < 0) { if (VIR_ALLOC(newBandwidth->out) < 0) {
virReportOOMError(); virReportOOMError();
goto cleanup; goto cleanup;
} }
if (bandwidth->out)
memcpy(newBandwidth->out, bandwidth->out, memcpy(newBandwidth->out,
sizeof(*newBandwidth->out)); bandwidth->out ? bandwidth->out : net->bandwidth->out,
else if (net->bandwidth->out)
memcpy(newBandwidth->out, net->bandwidth->out,
sizeof(*newBandwidth->out)); sizeof(*newBandwidth->out));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册