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:
Peter Krempa 2022-08-04 15:47:31 +02:00
parent 0d278aa089
commit 3de56902d3
1 changed files with 4 additions and 10 deletions

View File

@ -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;
}
/**