virCommandSetSendBuffer: Take double pointer of @buffer

The virCommandSetSendBuffer() function consumes passed @buffer,
but takes it only as plain pointer. Switch to a double pointer to
make this obvious. This allows us then to drop all
g_steal_pointer() in callers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
Michal Privoznik 2022-03-22 12:12:02 +01:00
parent 5690c9594e
commit 5c1b5f208a
4 changed files with 7 additions and 7 deletions

View File

@ -265,7 +265,7 @@ qemuTPMSetupEncryption(const unsigned char *secretuuid,
&secret, &secret_len) < 0)
return -1;
*fd = virCommandSetSendBuffer(cmd, g_steal_pointer(&secret), secret_len);
*fd = virCommandSetSendBuffer(cmd, &secret, secret_len);
return 0;
}

View File

@ -1699,10 +1699,10 @@ virCommandFreeSendBuffers(virCommand *cmd)
*/
int
virCommandSetSendBuffer(virCommand *cmd,
unsigned char *buffer,
unsigned char **buffer,
size_t buflen)
{
g_autofree unsigned char *localbuf = g_steal_pointer(&buffer);
g_autofree unsigned char *localbuf = g_steal_pointer(buffer);
int pipefd[2] = { -1, -1 };
size_t i;
@ -2901,7 +2901,7 @@ int virCommandHandshakeNotify(virCommand *cmd)
#else /* WIN32 */
int
virCommandSetSendBuffer(virCommand *cmd,
unsigned char *buffer G_GNUC_UNUSED,
unsigned char **buffer G_GNUC_UNUSED,
size_t buflen G_GNUC_UNUSED)
{
if (virCommandHasError(cmd))

View File

@ -132,7 +132,7 @@ void virCommandSetWorkingDirectory(virCommand *cmd,
const char *pwd) ATTRIBUTE_NONNULL(2);
int virCommandSetSendBuffer(virCommand *cmd,
unsigned char *buffer,
unsigned char **buffer,
size_t buflen)
ATTRIBUTE_NONNULL(2);

View File

@ -1075,8 +1075,8 @@ static int test27(const void *unused G_GNUC_UNUSED)
errexpect = g_strdup_printf(TEST27_ERREXPECT_TEMP,
buffer0, buffer1, buffer2);
buf1fd = virCommandSetSendBuffer(cmd, g_steal_pointer(&buffer1), buflen - 1);
buf2fd = virCommandSetSendBuffer(cmd, g_steal_pointer(&buffer2), buflen - 1);
buf1fd = virCommandSetSendBuffer(cmd, &buffer1, buflen - 1);
buf2fd = virCommandSetSendBuffer(cmd, &buffer2, buflen - 1);
virCommandAddArg(cmd, "--readfd");
virCommandAddArgFormat(cmd, "%d", buf1fd);