mirror of https://gitee.com/openkylin/libvirt.git
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)
|
||||
return NULL;
|
||||
|
||||
virCheckConnectGoto(conn, error);
|
||||
virCheckNonNullArgGoto(name, error);
|
||||
virCheckNonNullArgGoto(uuid, error);
|
||||
|
||||
if (!(ret = virObjectNew(virDomainClass)))
|
||||
goto error;
|
||||
virCheckConnectReturn(conn, NULL);
|
||||
virCheckNonNullArgReturn(name, NULL);
|
||||
virCheckNonNullArgReturn(uuid, NULL);
|
||||
|
||||
ret = virObjectNew(virDomainClass);
|
||||
ret->name = g_strdup(name);
|
||||
|
||||
ret->conn = virObjectRef(conn);
|
||||
|
@ -306,10 +304,6 @@ virGetDomain(virConnectPtr conn,
|
|||
memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
|
||||
|
||||
return ret;
|
||||
|
||||
error:
|
||||
virObjectUnref(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue