mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
util: virNetDevBandwidthUpdateRate: refactor
Use automatic cleanup and remove the 'ret' variable in favor of direct returns. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
aa9cd08d92
commit
6f8ac7bc46
@ -685,11 +685,10 @@ virNetDevBandwidthUpdateRate(const char *ifname,
|
|||||||
virNetDevBandwidth *bandwidth,
|
virNetDevBandwidth *bandwidth,
|
||||||
unsigned long long new_rate)
|
unsigned long long new_rate)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
virCommand *cmd = NULL;
|
g_autofree char *class_id = NULL;
|
||||||
char *class_id = NULL;
|
g_autofree char *rate = NULL;
|
||||||
char *rate = NULL;
|
g_autofree char *ceil = NULL;
|
||||||
char *ceil = NULL;
|
|
||||||
|
|
||||||
class_id = g_strdup_printf("1:%x", id);
|
class_id = g_strdup_printf("1:%x", id);
|
||||||
rate = g_strdup_printf("%llukbps", new_rate);
|
rate = g_strdup_printf("%llukbps", new_rate);
|
||||||
@ -703,17 +702,7 @@ virNetDevBandwidthUpdateRate(const char *ifname,
|
|||||||
"ceil", ceil, NULL);
|
"ceil", ceil, NULL);
|
||||||
virNetDevBandwidthCmdAddOptimalQuantum(cmd, bandwidth->in);
|
virNetDevBandwidthCmdAddOptimalQuantum(cmd, bandwidth->in);
|
||||||
|
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
return virCommandRun(cmd, NULL);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virCommandFree(cmd);
|
|
||||||
VIR_FREE(class_id);
|
|
||||||
VIR_FREE(rate);
|
|
||||||
VIR_FREE(ceil);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user