mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
util: virNetDevBandwidthClear: use g_auto
Separate the two uses of 'cmd' to avoid mixing manual and automatic cleanup. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
e1470a2295
commit
470987a53f
@ -416,27 +416,24 @@ virNetDevBandwidthClear(const char *ifname)
|
||||
{
|
||||
int ret = 0;
|
||||
int dummy; /* for ignoring the exit status */
|
||||
virCommand *cmd = NULL;
|
||||
g_autoptr(virCommand) rootcmd = NULL;
|
||||
g_autoptr(virCommand) ingresscmd = NULL;
|
||||
|
||||
if (!ifname)
|
||||
return 0;
|
||||
|
||||
cmd = virCommandNew(TC);
|
||||
virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "root", NULL);
|
||||
rootcmd = virCommandNew(TC);
|
||||
virCommandAddArgList(rootcmd, "qdisc", "del", "dev", ifname, "root", NULL);
|
||||
|
||||
if (virCommandRun(cmd, &dummy) < 0)
|
||||
if (virCommandRun(rootcmd, &dummy) < 0)
|
||||
ret = -1;
|
||||
|
||||
virCommandFree(cmd);
|
||||
ingresscmd = virCommandNew(TC);
|
||||
virCommandAddArgList(ingresscmd, "qdisc", "del", "dev", ifname, "ingress", NULL);
|
||||
|
||||
cmd = virCommandNew(TC);
|
||||
virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "ingress", NULL);
|
||||
|
||||
if (virCommandRun(cmd, &dummy) < 0)
|
||||
if (virCommandRun(ingresscmd, &dummy) < 0)
|
||||
ret = -1;
|
||||
|
||||
virCommandFree(cmd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user