]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: virNetDevBandwidthClear: use g_auto
authorJán Tomko <jtomko@redhat.com>
Mon, 17 Jan 2022 17:02:31 +0000 (18:02 +0100)
committerJán Tomko <jtomko@redhat.com>
Fri, 28 Jan 2022 19:38:44 +0000 (20:38 +0100)
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>
src/util/virnetdevbandwidth.c

index fe354696f2ca71f8aba52c7e381a12de1a3a1cf1..cb9a22a3691457a6c92fdddaf940fd510438c21f 100644 (file)
@@ -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;
 }