On 1/5/23 10:29 AM, Peter Krempa wrote:
'virObjectNew' can't return NULL. If we pre-check the
arguments we don't
need a cleanup label.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/datatypes.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/datatypes.c b/src/datatypes.c
index da8a9970f1..c83a74edd5 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -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;
}
/**
Reviewed-by: Jonathon Jongsma <jjongsma(a)redhat.com>