]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
utils: Convert pollfd array to be allocated
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Thu, 25 Jul 2019 18:22:07 +0000 (14:22 -0400)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 26 Jul 2019 09:30:53 +0000 (10:30 +0100)
Convert the struct pollfd *fds to be allocated rather than residing
on the stack. This prepares it for the next patch where the size of
the array of fds becomes dynamic.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/util/vircommand.c

index c42e14bc4d6efa06dee91e9a968c2b46a276a2d0..94b2ebc8aa54f5e4401c3b13649b1d7436703121 100644 (file)
@@ -2142,6 +2142,7 @@ virCommandProcessIO(virCommandPtr cmd)
     size_t inlen = 0, outlen = 0, errlen = 0;
     size_t inoff = 0;
     int ret = 0;
+    VIR_AUTOFREE(struct pollfd *) fds = NULL;
 
     if (dryRunBuffer || dryRunCallback) {
         VIR_DEBUG("Dry run requested, skipping I/O processing");
@@ -2173,9 +2174,11 @@ virCommandProcessIO(virCommandPtr cmd)
         goto cleanup;
     ret = -1;
 
+    if (VIR_ALLOC_N(fds, 3) < 0)
+        goto cleanup;
+
     for (;;) {
         size_t i;
-        struct pollfd fds[3];
         int nfds = 0;
 
         if (cmd->inpipe != -1) {