diff options
| author | Volker Lendecke <vl@samba.org> | 2014-12-27 16:48:55 +0000 |
|---|---|---|
| committer | Jeremy Allison <jra@samba.org> | 2014-12-30 00:25:08 +0100 |
| commit | 2e431289120681771e4791bdd7aae4397855e187 (patch) | |
| tree | df13255bf617716c3192b525fef99e19bc700d3e /source3/lib | |
| parent | 475cfb8dee6cdb5a89e8f15b32ad3886f949005f (diff) | |
| download | samba-2e431289120681771e4791bdd7aae4397855e187.tar.gz samba-2e431289120681771e4791bdd7aae4397855e187.tar.xz samba-2e431289120681771e4791bdd7aae4397855e187.zip | |
lib: Use iov_advance in write_data_iov
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/lib')
| -rw-r--r-- | source3/lib/sys_rw_data.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/source3/lib/sys_rw_data.c b/source3/lib/sys_rw_data.c index 353dbe75c2..88e5085ac6 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); |
