Fix kvec iterators

A few of the kvec iterators that work with byte offsets forgot to reset
the offsets as they advanced to the next vec.

These should probably be refactored into a set of iterator helpers.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2016-12-08 08:42:46 -08:00
parent be98c4dfd8
commit 471405f8cd

View File

@@ -50,11 +50,15 @@ int scoutfs_kvec_memcmp(struct kvec *a, struct kvec *b)
return ret;
b_off += len;
if (b_off == b->iov_len)
if (b_off == b->iov_len) {
b++;
b_off = 0;
}
a_off += len;
if (a_off == a->iov_len)
if (a_off == a->iov_len) {
a++;
a_off = 0;
}
}
return a->iov_base ? 1 : b->iov_base ? -1 : 0;
@@ -102,11 +106,15 @@ int scoutfs_kvec_memcpy(struct kvec *dst, struct kvec *src)
copied += len;
src_off += len;
if (src_off == src->iov_len)
if (src_off == src->iov_len) {
src++;
src_off = 0;
}
dst_off += len;
if (dst_off == dst->iov_len)
if (dst_off == dst->iov_len) {
dst++;
dst_off = 0;
}
}
return copied;