virNetMessageEncodePayloadEmpty: Replace by virNetMessageEncodePayloadRaw(msg, NULL, 0)

Replace the two outstanding invocations and remove the function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Claudio Fontana <cfontana@suse.de>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2022-05-25 10:59:48 +02:00
parent 9a86592c4e
commit 24049c06d9
4 changed files with 3 additions and 35 deletions

View File

@ -91,7 +91,7 @@ virKeepAliveMessage(virKeepAlive *ka, int proc)
msg->header.proc = proc;
if (virNetMessageEncodeHeader(msg) < 0 ||
virNetMessageEncodePayloadEmpty(msg) < 0) {
virNetMessageEncodePayloadRaw(msg, NULL, 0) < 0) {
virNetMessageFree(msg);
goto error;
}

View File

@ -496,31 +496,6 @@ int virNetMessageEncodePayloadRaw(virNetMessage *msg,
}
int virNetMessageEncodePayloadEmpty(virNetMessage *msg)
{
XDR xdr;
unsigned int msglen;
/* Re-encode the length word. */
VIR_DEBUG("Encode length as %zu", msg->bufferOffset);
xdrmem_create(&xdr, msg->buffer, VIR_NET_MESSAGE_HEADER_XDR_LEN, XDR_ENCODE);
msglen = msg->bufferOffset;
if (!xdr_u_int(&xdr, &msglen)) {
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message length"));
goto error;
}
xdr_destroy(&xdr);
msg->bufferLength = msg->bufferOffset;
msg->bufferOffset = 0;
return 0;
error:
xdr_destroy(&xdr);
return -1;
}
void virNetMessageSaveError(struct virNetMessageError *rerr)
{
virErrorPtr verr;

View File

@ -85,8 +85,6 @@ int virNetMessageEncodePayloadRaw(virNetMessage *msg,
const char *buf,
size_t len)
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
int virNetMessageEncodePayloadEmpty(virNetMessage *msg)
ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
void virNetMessageSaveError(struct virNetMessageError *rerr)
ATTRIBUTE_NONNULL(1);

View File

@ -518,14 +518,9 @@ int virNetServerProgramSendStreamData(virNetServerProgram *prog,
if (virNetMessageEncodeHeader(msg) < 0)
return -1;
if (data && len) {
if (virNetMessageEncodePayloadRaw(msg, data, len) < 0)
return -1;
} else {
if (virNetMessageEncodePayloadEmpty(msg) < 0)
return -1;
}
VIR_DEBUG("Total %zu", msg->bufferLength);
return virNetServerClientSendMessage(client, msg);