[libvirt] [PATCH v2 14/21] utils: Convert pollfd array to be allocated

Marc-André Lureau marcandre.lureau at redhat.com
Wed Jul 10 18:47:22 UTC 2019


On Wed, Jul 10, 2019 at 10:12 PM Stefan Berger
<stefanb at linux.vnet.ibm.com> wrote:
>
> Convert the struct pollfd *fds to be allocated rather than residing
> on the stack.
>

why? give some context to the commit message. thanks

> Signed-off-by: Stefan Berger <stefanb at linux.ibm.com>
> ---
>  src/util/vircommand.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/util/vircommand.c b/src/util/vircommand.c
> index e32377497b..898ee0df45 100644
> --- a/src/util/vircommand.c
> +++ b/src/util/vircommand.c
> @@ -2123,6 +2123,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");
> @@ -2154,9 +2155,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) {
> --
> 2.20.1
>




More information about the libvir-list mailing list