int qio_channel_writev_all(QIOChannel *ioc,

                           const struct iovec *iov,

                           size_t niov,

                           Error **errp)

{

    int ret = -1;

    struct iovec *local_iov = g_new(struct iovec, niov);

    struct iovec *local_iov_head = local_iov;

    unsigned int nlocal_iov = niov;



    nlocal_iov = iov_copy(local_iov, nlocal_iov,

                          iov, niov,

                          0, iov_size(iov, niov));



    while (nlocal_iov > 0) {

        ssize_t len;

        len = qio_channel_writev(ioc, local_iov, nlocal_iov, errp);

        if (len == QIO_CHANNEL_ERR_BLOCK) {

            qio_channel_wait(ioc, G_IO_OUT);

            continue;

        }

        if (len < 0) {

            goto cleanup;

        }



        iov_discard_front(&local_iov, &nlocal_iov, len);

    }



    ret = 0;

 cleanup:

    g_free(local_iov_head);

    return ret;

}

int qio_channel_writev_all(QIOChannel *ioc,

                           const struct iovec *iov,

                           size_t niov,

                           Error **errp)

{

    int ret = -1;

    struct iovec *local_iov = g_new(struct iovec, niov);

    struct iovec *local_iov_head = local_iov;

    unsigned int nlocal_iov = niov;



    nlocal_iov = iov_copy(local_iov, nlocal_iov,

                          iov, niov,

                          0, iov_size(iov, niov));



    while (nlocal_iov > 0) {

        ssize_t len;

        len = qio_channel_writev(ioc, local_iov, nlocal_iov, errp);

        if (len == QIO_CHANNEL_ERR_BLOCK) {

            qio_channel_wait(ioc, G_IO_OUT);

            continue;

        }

        if (len < 0) {

            goto cleanup;

        }



        iov_discard_front(&local_iov, &nlocal_iov, len);

    }



    ret = 0;

 cleanup:

    g_free(local_iov_head);

    return ret;

}

int FUNC_0(QIOChannel *VAR_0,

                           const struct iovec *VAR_1,

                           size_t VAR_2,

                           Error **VAR_3)

{

    int VAR_4 = -1;

    struct iovec *VAR_5 = g_new(struct iovec, VAR_2);

    struct iovec *VAR_6 = VAR_5;

    unsigned int VAR_7 = VAR_2;



    VAR_7 = iov_copy(VAR_5, VAR_7,

                          VAR_1, VAR_2,

                          0, iov_size(VAR_1, VAR_2));



    while (VAR_7 > 0) {

        ssize_t len;

        len = qio_channel_writev(VAR_0, VAR_5, VAR_7, VAR_3);

        if (len == QIO_CHANNEL_ERR_BLOCK) {

            qio_channel_wait(VAR_0, G_IO_OUT);

            continue;

        }

        if (len < 0) {

            goto cleanup;

        }



        iov_discard_front(&VAR_5, &VAR_7, len);

    }



    VAR_4 = 0;

 cleanup:

    g_free(VAR_6);

    return VAR_4;

}

int FUNC_0(QIOChannel *VAR_0,
const struct iovec *VAR_1,
size_t VAR_2,
Error **VAR_3)
{ int VAR_4 = -1; struct iovec *VAR_5 = g_new(struct iovec, VAR_2); struct iovec *VAR_6 = VAR_5; unsigned int VAR_7 = VAR_2; VAR_7 = iov_copy(VAR_5, VAR_7,
VAR_1, VAR_2,
0, iov_size(VAR_1, VAR_2)); while (VAR_7 > 0) { ssize_t len; len = qio_channel_writev(VAR_0, VAR_5, VAR_7, VAR_3); if (len == QIO_CHANNEL_ERR_BLOCK) { qio_channel_wait(VAR_0, G_IO_OUT); continue; } if (len < 0) { goto cleanup; } iov_discard_front(&VAR_5, &VAR_7, len); } VAR_4 = 0; cleanup:
g_free(VAR_6); return VAR_4; }