This patch is intentionally wrong (it's leaking memory). I just
include it to illustrate Clang bug.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/rpc/virnetclient.c | 9 ++++++---
src/util/viridentity.c | 3 ++-
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index ffe2f343f9..eb215f13db 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -882,7 +882,7 @@ virNetClientIOEventTLS(int fd,
static gboolean
virNetClientTLSHandshake(virNetClient *client)
{
- g_autoptr(GSource) source = NULL;
+ GSource *source = NULL;
GIOCondition ev;
int ret;
@@ -901,6 +901,7 @@ virNetClientTLSHandshake(virNetClient *client)
ev,
client->eventCtx,
virNetClientIOEventTLS, client, NULL);
+ g_source_unref(source);
return TRUE;
}
@@ -939,7 +940,7 @@ int virNetClientSetTLSSession(virNetClient *client,
int ret;
char buf[1];
int len;
- g_autoptr(GSource) source = NULL;
+ GSource *source = NULL;
#ifndef WIN32
sigset_t oldmask, blockedsigs;
@@ -1028,6 +1029,7 @@ int virNetClientSetTLSSession(virNetClient *client,
virObjectUnref(client->tls);
client->tls = NULL;
virObjectUnlock(client);
+ g_source_unref(source);
return -1;
}
@@ -1664,7 +1666,7 @@ static int virNetClientIOEventLoop(virNetClient *client,
#endif /* !WIN32 */
int timeout = -1;
virNetMessage *msg = NULL;
- g_autoptr(GSource) source = NULL;
+ GSource *source = NULL;
GIOCondition ev = 0;
struct virNetClientIOEventData data = {
.client = client,
@@ -1810,6 +1812,7 @@ static int virNetClientIOEventLoop(virNetClient *client,
virNetClientMarkClose(client, closeReason);
goto error;
}
+ g_source_unref(source);
}
error:
diff --git a/src/util/viridentity.c b/src/util/viridentity.c
index e36e54ae4b..dbaacd6da5 100644
--- a/src/util/viridentity.c
+++ b/src/util/viridentity.c
@@ -134,12 +134,13 @@ virIdentity *virIdentityGetCurrent(void)
*/
int virIdentitySetCurrent(virIdentity *ident)
{
- g_autoptr(virIdentity) old = NULL;
+ virIdentity *old = NULL;
if (virIdentityInitialize() < 0)
return -1;
old = virThreadLocalGet(&virIdentityCurrent);
+ g_clear_object(&old);
if (virThreadLocalSet(&virIdentityCurrent,
ident ? g_object_ref(ident) : NULL) < 0) {
--
2.31.1