From 2e431289120681771e4791bdd7aae4397855e187 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 27 Dec 2014 16:48:55 +0000 Subject: [PATCH] lib: Use iov_advance in write_data_iov Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/lib/sys_rw_data.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/source3/lib/sys_rw_data.c b/source3/lib/sys_rw_data.c index 353dbe75c2d..88e5085ac69 100644 --- a/source3/lib/sys_rw_data.c +++ b/source3/lib/sys_rw_data.c @@ -63,22 +63,12 @@ ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt) iov = iov_copy; while (sent < to_send) { - /* - * We have to discard "thistime" bytes from the beginning - * iov array, "thistime" contains the number of bytes sent - * via writev last. - */ - while (thistime > 0) { - if (thistime < iov[0].iov_len) { - char *new_base = - (char *)iov[0].iov_base + thistime; - iov[0].iov_base = (void *)new_base; - iov[0].iov_len -= thistime; - break; - } - thistime -= iov[0].iov_len; - iov += 1; - iovcnt -= 1; + bool ok; + + ok = iov_advance(&iov, &iovcnt, thistime); + if (!ok) { + errno = EIO; + return -1; } thistime = sys_writev(fd, iov, iovcnt); -- 2.11.4.GIT