csum_and_copy_..._user(): pass 0xffffffff instead of 0 as initial sum
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 12 Jul 2020 03:51:04 +0000 (23:51 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 20 Aug 2020 19:45:15 +0000 (15:45 -0400)
Preparation for the change of calling conventions; right now all
callers pass 0 as initial sum.  Passing 0xffffffff instead yields
the values comparable mod 0xffff and guarantees that 0 will not
be returned on success.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
lib/iov_iter.c

index 84f3a91..437fbc1 100644 (file)
@@ -1452,7 +1452,7 @@ size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum,
                int err = 0;
                next = csum_and_copy_from_user(v.iov_base,
                                               (to += v.iov_len) - v.iov_len,
-                                              v.iov_len, 0, &err);
+                                              v.iov_len, ~0U, &err);
                if (!err) {
                        sum = csum_block_add(sum, next, off);
                        off += v.iov_len;
@@ -1494,7 +1494,7 @@ bool csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum,
                int err = 0;
                next = csum_and_copy_from_user(v.iov_base,
                                               (to += v.iov_len) - v.iov_len,
-                                              v.iov_len, 0, &err);
+                                              v.iov_len, ~0U, &err);
                if (err)
                        return false;
                sum = csum_block_add(sum, next, off);
@@ -1540,7 +1540,7 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump,
                int err = 0;
                next = csum_and_copy_to_user((from += v.iov_len) - v.iov_len,
                                             v.iov_base,
-                                            v.iov_len, 0, &err);
+                                            v.iov_len, ~0U, &err);
                if (!err) {
                        sum = csum_block_add(sum, next, off);
                        off += v.iov_len;