This method will always succeed.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/remote/remote_daemon_dispatch.c | 5 +----
src/rpc/virnetserverclient.c | 5 +----
src/util/viridentity.c | 5 +----
3 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index 69d0a015ba..0e38b314a2 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -2192,7 +2192,7 @@ remoteDispatchConnectSetIdentity(virNetServer *server
G_GNUC_UNUSED,
int nparams = 0;
int rv = -1;
virConnectPtr conn = remoteGetHypervisorConn(client);
- g_autoptr(virIdentity) ident = NULL;
+ g_autoptr(virIdentity) ident = virIdentityNew();
if (!conn)
goto cleanup;
@@ -2209,9 +2209,6 @@ remoteDispatchConnectSetIdentity(virNetServer *server
G_GNUC_UNUSED,
if (virConnectSetIdentityEnsureACL(conn) < 0)
goto cleanup;
- if (!(ident = virIdentityNew()))
- goto cleanup;
-
if (virIdentitySetParameters(ident, params, nparams) < 0)
goto cleanup;
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 236702ced6..7050430e17 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -747,10 +747,7 @@ virNetServerClientCreateIdentity(virNetServerClient *client)
g_autofree char *username = NULL;
g_autofree char *groupname = NULL;
g_autofree char *seccontext = NULL;
- g_autoptr(virIdentity) ret = NULL;
-
- if (!(ret = virIdentityNew()))
- return NULL;
+ g_autoptr(virIdentity) ret = virIdentityNew();
if (client->sock && virNetSocketIsLocal(client->sock)) {
gid_t gid;
diff --git a/src/util/viridentity.c b/src/util/viridentity.c
index c18326c8cb..e36e54ae4b 100644
--- a/src/util/viridentity.c
+++ b/src/util/viridentity.c
@@ -313,15 +313,12 @@ virIdentity *virIdentityGetSystem(void)
g_autofree char *username = NULL;
g_autofree char *groupname = NULL;
unsigned long long startTime;
- g_autoptr(virIdentity) ret = NULL;
+ g_autoptr(virIdentity) ret = virIdentityNew();
#if WITH_SELINUX
char *con;
#endif
g_autofree char *token = NULL;
- if (!(ret = virIdentityNew()))
- return NULL;
-
if (virIdentitySetProcessID(ret, getpid()) < 0)
return NULL;
--
2.31.1