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.