1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

virFDStreamMsgQueuePush: Clear pointer to passed message

All callers of virFDStreamMsgQueuePush() have the same pattern:
they explicitly set @msg passed to NULL to avoid freeing it later
on. Well, the function can take address of the pointer and clear
it for them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Michal Privoznik 2020-07-07 13:08:46 +02:00
parent 8d5cae317e
commit 211ea0d20c

View File

@ -140,7 +140,7 @@ VIR_ONCE_GLOBAL_INIT(virFDStreamData);
static int static int
virFDStreamMsgQueuePush(virFDStreamDataPtr fdst, virFDStreamMsgQueuePush(virFDStreamDataPtr fdst,
virFDStreamMsgPtr msg, virFDStreamMsgPtr *msg,
int fd, int fd,
const char *fdname) const char *fdname)
{ {
@ -150,7 +150,7 @@ virFDStreamMsgQueuePush(virFDStreamDataPtr fdst,
while (*tmp) while (*tmp)
tmp = &(*tmp)->next; tmp = &(*tmp)->next;
*tmp = msg; *tmp = g_steal_pointer(msg);
virCondSignal(&fdst->threadCond); virCondSignal(&fdst->threadCond);
if (safewrite(fd, &c, sizeof(c)) != sizeof(c)) { if (safewrite(fd, &c, sizeof(c)) != sizeof(c)) {
@ -489,8 +489,7 @@ virFDStreamThreadDoRead(virFDStreamDataPtr fdst,
*dataLen -= got; *dataLen -= got;
} }
virFDStreamMsgQueuePush(fdst, msg, fdout, fdoutname); virFDStreamMsgQueuePush(fdst, &msg, fdout, fdoutname);
msg = NULL;
return got; return got;
@ -814,8 +813,7 @@ static int virFDStreamWrite(virStreamPtr st, const char *bytes, size_t nbytes)
msg->stream.data.buf = buf; msg->stream.data.buf = buf;
msg->stream.data.len = nbytes; msg->stream.data.len = nbytes;
virFDStreamMsgQueuePush(fdst, msg, fdst->fd, "pipe"); virFDStreamMsgQueuePush(fdst, &msg, fdst->fd, "pipe");
msg = NULL;
ret = nbytes; ret = nbytes;
} else { } else {
retry: retry:
@ -1010,8 +1008,7 @@ virFDStreamSendHole(virStreamPtr st,
msg->type = VIR_FDSTREAM_MSG_TYPE_HOLE; msg->type = VIR_FDSTREAM_MSG_TYPE_HOLE;
msg->stream.hole.len = length; msg->stream.hole.len = length;
virFDStreamMsgQueuePush(fdst, msg, fdst->fd, "pipe"); virFDStreamMsgQueuePush(fdst, &msg, fdst->fd, "pipe");
msg = NULL;
} }
} else { } else {
off = lseek(fdst->fd, length, SEEK_CUR); off = lseek(fdst->fd, length, SEEK_CUR);