Re: [PATCH 1/2] openvz_driver: use g_autofree instead of VIR_FREE in openvz_driver.c

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

 



On 3/17/24 16:19, Karim Taha wrote:
> Signed-off-by: Karim Taha <kariem.taha2.7@xxxxxxxxx>
> ---
>  src/openvz/openvz_driver.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
> index 1bd96dfb56..fd3c25a393 100644
> --- a/src/openvz/openvz_driver.c
> +++ b/src/openvz/openvz_driver.c
> @@ -615,7 +615,7 @@ openvzGenerateVethName(int veid, char *dev_name_ve)
>  static char *
>  openvzGenerateContainerVethName(int veid)
>  {
> -    char *temp = NULL;
> +    g_autofree char *temp = NULL;
>      char *name = NULL;
> 
>      /* try to get line "^NETIF=..." from config */
> @@ -638,8 +638,6 @@ openvzGenerateContainerVethName(int veid)
>          name = g_strdup_printf("eth%d", max + 1);
>      }
> 
> -    VIR_FREE(temp);
> -
>      return name;
>  }
> 
> @@ -750,7 +748,7 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
>  {
>      size_t i;
>      g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
> -    char *param;
> +    g_autofree char *param = NULL;

We can take this opportunity and move this declaration ...

>      int first = 1;
>      struct openvz_driver *driver =  conn->privateData;
> 
> @@ -774,12 +772,10 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,

... here. It's only used inside this block.

>          param = virBufferContentAndReset(&buf);
>          if (param) {
>              if (openvzWriteVPSConfigParam(strtoI(def->name), "NETIF", param) < 0) {
> -                VIR_FREE(param);
>                  virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>                                 _("cannot replace NETIF config"));
>                  return -1;
>              }
> -            VIR_FREE(param);
>          }
>      }
> 

Michal
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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