[PATCH v2 5/7] virCommandSetSendBuffer: Take double pointer of @buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/qemu/qemu_tpm.c   | 2 +-
 src/util/vircommand.c | 6 +++---
 src/util/vircommand.h | 2 +-
 tests/commandtest.c   | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c
index 56bccee128..28d2b07903 100644
--- a/src/qemu/qemu_tpm.c
+++ b/src/qemu/qemu_tpm.c
@@ -265,7 +265,7 @@ qemuTPMSetupEncryption(const unsigned char *secretuuid,
                                  &secret, &secret_len) < 0)
         return -1;
 
-    return virCommandSetSendBuffer(cmd, g_steal_pointer(&secret), secret_len);
+    return virCommandSetSendBuffer(cmd, &secret, secret_len);
 }
 
 
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index ebd986cb13..ff0e60936b 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -1725,10 +1725,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;
 
@@ -2927,7 +2927,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))
diff --git a/src/util/vircommand.h b/src/util/vircommand.h
index 600806a987..63ae9b8a61 100644
--- a/src/util/vircommand.h
+++ b/src/util/vircommand.h
@@ -140,7 +140,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);
 
diff --git a/tests/commandtest.c b/tests/commandtest.c
index 9d4de151f0..10a051124d 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -1077,8 +1077,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);
-- 
2.34.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux