Re: [PATCH] util: convert char pointers to use g_autofree

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

 



On Mon, Nov 09, 2020 at 04:34:22PM -0600, Ryan Gahagan wrote:
> From: Barrett Schonefeld <bschoney@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx>
> Signed-off-by: Barrett Schonefeld <bschoney@xxxxxxxxxx>
> ---
>  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

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