diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2021-06-05 10:19:30 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2021-06-10 11:45:14 -0400 |
commit | 594e450b3f4435a9d663df3d48d7fa34e685cbd1 (patch) | |
tree | 59b3a48032406362876577688e0785f0fc9fcb13 /lib/iov_iter.c | |
parent | f0b65f39ac505e8f1dcdaa165aa7b8c0bd6fd454 (diff) | |
download | lwn-594e450b3f4435a9d663df3d48d7fa34e685cbd1.tar.gz lwn-594e450b3f4435a9d663df3d48d7fa34e685cbd1.zip |
csum_and_copy_to_iter(): massage into form closer to csum_and_copy_from_iter()
Namely, have off counted starting from 0 rather than from csstate->off.
To compensate we need to shift the initial value (csstate->sum) (rotate
by 8 bits, as usual for csum) and do the same after we are finished adding
the pieces up.
What we get out of that is a bit more redundancy in our variables - from
is always equal to addr + off, which will be useful several commits down
the road.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'lib/iov_iter.c')
-rw-r--r-- | lib/iov_iter.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 362e8b5a5dc5..93ae0c2c8d66 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -1781,8 +1781,8 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *_csstate, if (unlikely(iov_iter_is_pipe(i))) return csum_and_copy_to_pipe_iter(addr, bytes, _csstate, i); - sum = csstate->csum; - off = csstate->off; + sum = csum_shift(csstate->csum, csstate->off); + off = 0; if (unlikely(iov_iter_is_discard(i))) { WARN_ON(1); /* for now */ return 0; @@ -1817,8 +1817,8 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *_csstate, off += v.bv_len; }) ) - csstate->csum = sum; - csstate->off = off; + csstate->csum = csum_shift(sum, csstate->off); + csstate->off += bytes; return bytes; } EXPORT_SYMBOL(csum_and_copy_to_iter); |