On a Monday in 2020, Ryan Gahagan wrote:
From: Barrett Schonefeld <bscho...@utexas.edu>

- src/util/virnetdevbandwidth.c

Signed-off-by: Barrett Schonefeld <bscho...@utexas.edu>
---
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

Reply via email to