mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
datatypes: Simplify error path of 'virGetDomain'
'virObjectNew' can't return NULL. If we pre-check the arguments we don't need a cleanup label. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
0d278aa089
commit
3de56902d3
@ -292,13 +292,11 @@ virGetDomain(virConnectPtr conn,
|
|||||||
if (virDataTypesInitialize() < 0)
|
if (virDataTypesInitialize() < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
virCheckConnectGoto(conn, error);
|
virCheckConnectReturn(conn, NULL);
|
||||||
virCheckNonNullArgGoto(name, error);
|
virCheckNonNullArgReturn(name, NULL);
|
||||||
virCheckNonNullArgGoto(uuid, error);
|
virCheckNonNullArgReturn(uuid, NULL);
|
||||||
|
|
||||||
if (!(ret = virObjectNew(virDomainClass)))
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
|
ret = virObjectNew(virDomainClass);
|
||||||
ret->name = g_strdup(name);
|
ret->name = g_strdup(name);
|
||||||
|
|
||||||
ret->conn = virObjectRef(conn);
|
ret->conn = virObjectRef(conn);
|
||||||
@ -306,10 +304,6 @@ virGetDomain(virConnectPtr conn,
|
|||||||
memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
|
memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
|
||||||
virObjectUnref(ret);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user