[PATCH 12/30] util: convert pointers to use g_autofree
Ján Tomko
jtomko at redhat.com
Tue Nov 24 12:07:25 UTC 2020
On a Monday in 2020, Ryan Gahagan wrote:
>From: Barrett Schonefeld <bschoney at utexas.edu>
>
>- src/util/virnetdevbandwidth.c
>
>Signed-off-by: Barrett Schonefeld <bschoney at 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
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20201124/9b4272e3/attachment-0001.sig>
More information about the libvir-list
mailing list