Re: [PATCH 20/36] datatypes: convert virNetworkPort to GObject

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

 



On Fri, 2020-04-03 at 17:15 +0200, Rafael Fonseca wrote:
> @@ -482,14 +495,14 @@ virNetworkFinalize(GObject *obj)
>   * @uuid: pointer to the uuid
>   *
>   * Allocates a new network port object. When the object is no longer
> needed,
> - * virObjectUnref() must be called in order to not leak data.
> + * g_object_unref() must be called in order to not leak data.
>   *
>   * Returns a pointer to the network port object, or NULL on error.
>   */
>  virNetworkPortPtr
>  virGetNetworkPort(virNetworkPtr net, const unsigned char *uuid)
>  {
> -    virNetworkPortPtr ret = NULL;
> +    g_autoptr(virNetworkPort) ret = NULL;
>  
>      if (virDataTypesInitialize() < 0)
>          return NULL;
> @@ -497,21 +510,19 @@ virGetNetworkPort(virNetworkPtr net, const
> unsigned char *uuid)
>      virCheckNetworkGoto(net, error);
>      virCheckNonNullArgGoto(uuid, error);
>  
> -    if (!(ret = virObjectNew(virNetworkPortClass)))
> -        goto error;
> +    ret = VIR_NETWORK_PORT(g_object_new(VIR_TYPE_NETWORK_PORT,
> NULL));
>  
>      ret->net = g_object_ref(net);
>      memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
>  
> -    return ret;
> +    return g_steal_pointer(&ret);
>  
>   error:
> -    virObjectUnref(ret);
>      return NULL;
>  }

As far as I can tell, you removed the only 'goto error' statement from
this function, so the error: label can be removed completely.






[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