[PATCH] util: convert char pointers to use g_autofree
Pavel Hrdina
phrdina at redhat.com
Tue Nov 10 08:32:33 UTC 2020
On Mon, Nov 09, 2020 at 04:34:22PM -0600, Ryan Gahagan wrote:
> From: Barrett Schonefeld <bschoney at utexas.edu>
>
> additional conversions to the GLib API in src/util per issue #11.
>
> files updated are:
> - src/util/vircgroupv1.c
> - src/util/virhostcpu.c
> - src/util/virlockspace.c
> - src/util/virmacmap.c
> - src/util/virresctrl.c
> - src/util/virsysinfo.c
>
> Related issue: https://gitlab.com/libvirt/libvirt/-/issues/11
>
> Signed-off-by: bschoney <bschoney at utexas.edu>
> Signed-off-by: Barrett Schonefeld <bschoney at utexas.edu>
> ---
> src/util/vircgroupv1.c | 3 +--
> src/util/virhostcpu.c | 4 +---
> src/util/virlockspace.c | 6 ++----
> src/util/virmacmap.c | 3 +--
> src/util/virresctrl.c | 25 ++++++++-----------------
> src/util/virsysinfo.c | 9 +++------
> 6 files changed, 16 insertions(+), 34 deletions(-)
>
> diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
> index 731e9d61d4..984cd50409 100644
> --- a/src/util/vircgroupv1.c
> +++ b/src/util/vircgroupv1.c
> @@ -1549,7 +1549,7 @@ virCgroupV1GetMemoryStat(virCgroupPtr group,
> unsigned long long *unevictable)
> {
> int ret = -1;
> - char *stat = NULL;
> + g_autofree char *stat = NULL;
> char *line = NULL;
> unsigned long long cacheVal = 0;
> unsigned long long activeAnonVal = 0;
> @@ -1614,7 +1614,6 @@ virCgroupV1GetMemoryStat(virCgroupPtr group,
> ret = 0;
>
> cleanup:
> - VIR_FREE(stat);
> return ret;
Usually the whole exercise of using g_autofree or g_autoptr is to
simplify the code by removing all the `goto` and cleanup labels
where it is possible.
Otherwise looks good.
Pavel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20201110/a86c9a6d/attachment-0001.sig>
More information about the libvir-list
mailing list