Re: [PATCH 12/30] util: convert pointers to use g_autofree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On a Monday in 2020, Ryan Gahagan wrote:
From: Barrett Schonefeld <bschoney@xxxxxxxxxx>

- src/util/virnetdevbandwidth.c

Signed-off-by: Barrett Schonefeld <bschoney@xxxxxxxxxx>
---
src/util/virnetdevbandwidth.c | 44 ++++++++++++-----------------------
1 file changed, 15 insertions(+), 29 deletions(-)

diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c
index c8eb5cfc79..364b39e3c1 100644
--- a/src/util/virnetdevbandwidth.c
+++ b/src/util/virnetdevbandwidth.c
@@ -195,9 +194,9 @@ virNetDevBandwidthSet(const char *ifname,
    int ret = -1;
    virNetDevBandwidthRatePtr rx = NULL, tx = NULL; /* From domain POV */
    virCommandPtr cmd = NULL;
-    char *average = NULL;
-    char *peak = NULL;
-    char *burst = NULL;
+    g_autofree char *average = NULL;
+    g_autofree char *peak = NULL;
+    g_autofree char *burst = NULL;

These are freed at multiple points in the function, but they can be
declared at the start of each 'if' block they're used in.


    if (!bandwidth) {
        /* nothing to be enabled */
@@ -385,9 +384,6 @@ virNetDevBandwidthSet(const char *ifname,

 cleanup:
    virCommandFree(cmd);
-    VIR_FREE(average);
-    VIR_FREE(peak);
-    VIR_FREE(burst);
    return ret;
}


[...]

@@ -733,8 +720,7 @@ virNetDevBandwidthUpdateFilter(const char *ifname,
                                           class_id, true, true) < 0)
        goto cleanup;

-    ret = 0;
+    return 0;

Unrelated change.

Jano

 cleanup:
-    VIR_FREE(class_id);
    return ret;
}
--
2.29.0

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux