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

View File

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