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

Re: [libvirt] [PATCH v1 21/32] util: netdevveth: use VIR_AUTOPTR for aggregate types



On Sat, Jul 28, 2018 at 11:31:36PM +0530, Sukrit Bhatnagar wrote:
> By making use of GNU C's cleanup attribute handled by the
> VIR_AUTOPTR macro for declaring aggregate pointer variables,
> majority of the calls to *Free functions can be dropped, which
> in turn leads to getting rid of most of our cleanup sections.
>
> Signed-off-by: Sukrit Bhatnagar <skrtbhtngr gmail com>
> ---
>  src/util/virnetdevveth.c | 21 +++++++--------------
>  1 file changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c
> index 8c1a7f3..0b94f73 100644
> --- a/src/util/virnetdevveth.c
> +++ b/src/util/virnetdevveth.c
> @@ -111,7 +111,6 @@ int virNetDevVethCreate(char** veth1, char** veth2)
>  {
>      int ret = -1;
>      int vethNum = 0;
> -    virCommandPtr cmd = NULL;
>      size_t i;
>
>      /*
> @@ -124,6 +123,7 @@ int virNetDevVethCreate(char** veth1, char** veth2)
>      for (i = 0; i < MAX_VETH_RETRIES; i++) {
>          VIR_AUTOFREE(char *) veth1auto = NULL;
>          VIR_AUTOFREE(char *) veth2auto = NULL;
> +        VIR_AUTOPTR(virCommand) cmd = NULL;
>
>          int status;
>          if (!*veth1) {
> @@ -173,8 +173,6 @@ int virNetDevVethCreate(char** veth1, char** veth2)
>                    *veth1 ? *veth1 : veth1auto,
>                    *veth2 ? *veth2 : veth2auto,
>                    status);
> -        virCommandFree(cmd);
> -        cmd = NULL;
>      }
>
>      virReportError(VIR_ERR_INTERNAL_ERROR,
> @@ -183,7 +181,6 @@ int virNetDevVethCreate(char** veth1, char** veth2)
>
>   cleanup:
>      virMutexUnlock(&virNetDevVethCreateMutex);
> -    virCommandFree(cmd);
>      return ret;
>  }
>
> @@ -200,26 +197,22 @@ int virNetDevVethCreate(char** veth1, char** veth2)
>   */
>  int virNetDevVethDelete(const char *veth)
>  {
> -    virCommandPtr cmd = virCommandNewArgList("ip", "link", "del", veth, NULL);
> +    VIR_AUTOPTR(virCommand) cmd = NULL;
> +    cmd = virCommandNewArgList("ip", "link", "del", veth, NULL);

I'll put this on a single line.

Reviewed-by: Erik Skultety <eskultet redhat com>


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