mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 09:55:18 +00:00
virfdstream: Use g_new0() instead of VIR_ALLOC()
This switch allow us to save a few lines of code. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
fb27b7b9be
commit
4bbe816d9f
@ -452,8 +452,7 @@ virFDStreamThreadDoRead(virFDStreamDataPtr fdst,
|
|||||||
buflen > length - total)
|
buflen > length - total)
|
||||||
buflen = length - total;
|
buflen = length - total;
|
||||||
|
|
||||||
if (VIR_ALLOC(msg) < 0)
|
msg = g_new0(virFDStreamMsg, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (sparse && *dataLen == 0) {
|
if (sparse && *dataLen == 0) {
|
||||||
msg->type = VIR_FDSTREAM_MSG_TYPE_HOLE;
|
msg->type = VIR_FDSTREAM_MSG_TYPE_HOLE;
|
||||||
@ -474,8 +473,7 @@ virFDStreamThreadDoRead(virFDStreamDataPtr fdst,
|
|||||||
buflen > *dataLen)
|
buflen > *dataLen)
|
||||||
buflen = *dataLen;
|
buflen = *dataLen;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(buf, buflen) < 0)
|
buf = g_new0(char, buflen);
|
||||||
goto error;
|
|
||||||
|
|
||||||
if ((got = saferead(fdin, buf, buflen)) < 0) {
|
if ((got = saferead(fdin, buf, buflen)) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
@ -805,9 +803,8 @@ static int virFDStreamWrite(virStreamPtr st, const char *bytes, size_t nbytes)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(msg) < 0 ||
|
msg = g_new0(virFDStreamMsg, 1);
|
||||||
VIR_ALLOC_N(buf, nbytes) < 0)
|
buf = g_new0(char, nbytes);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
memcpy(buf, bytes, nbytes);
|
memcpy(buf, bytes, nbytes);
|
||||||
msg->type = VIR_FDSTREAM_MSG_TYPE_DATA;
|
msg->type = VIR_FDSTREAM_MSG_TYPE_DATA;
|
||||||
@ -1003,8 +1000,7 @@ virFDStreamSendHole(virStreamPtr st,
|
|||||||
|
|
||||||
virFDStreamMsgQueuePop(fdst, fdst->fd, "pipe");
|
virFDStreamMsgQueuePop(fdst, fdst->fd, "pipe");
|
||||||
} else {
|
} else {
|
||||||
if (VIR_ALLOC(msg) < 0)
|
msg = g_new0(virFDStreamMsg, 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
msg->type = VIR_FDSTREAM_MSG_TYPE_HOLE;
|
msg->type = VIR_FDSTREAM_MSG_TYPE_HOLE;
|
||||||
msg->stream.hole.len = length;
|
msg->stream.hole.len = length;
|
||||||
@ -1123,8 +1119,7 @@ static int virFDStreamOpenInternal(virStreamPtr st,
|
|||||||
|
|
||||||
/* Create the thread after fdst and st were initialized.
|
/* Create the thread after fdst and st were initialized.
|
||||||
* The thread worker expects them to be that way. */
|
* The thread worker expects them to be that way. */
|
||||||
if (VIR_ALLOC(fdst->thread) < 0)
|
fdst->thread = g_new0(virThread, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (virCondInit(&fdst->threadCond) < 0) {
|
if (virCondInit(&fdst->threadCond) < 0) {
|
||||||
virReportSystemError(errno, "%s",
|
virReportSystemError(errno, "%s",
|
||||||
@ -1277,8 +1272,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
|
|||||||
if (virPipe(pipefds) < 0)
|
if (virPipe(pipefds) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (VIR_ALLOC(threadData) < 0)
|
threadData = g_new0(virFDStreamThreadData, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
threadData->st = virObjectRef(st);
|
threadData->st = virObjectRef(st);
|
||||||
threadData->length = length;
|
threadData->length = length;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user