diff mbox series

[RFC,22/37] iterate_and_advance(): get rid of magic in case when n is 0

Message ID 20210606191051.1216821-22-viro@zeniv.linux.org.uk (mailing list archive)
State New, archived
Headers show
Series [RFC,01/37] ntfs_copy_from_user_iter(): don't bother with copying iov_iter | expand

Commit Message

Al Viro June 6, 2021, 7:10 p.m. UTC
iov_iter_advance() needs to do some non-trivial work when it's given
0 as argument (skip all empty iovecs, mostly).  We used to implement
it via iterate_and_advance(); we no longer do so and for all other
users of iterate_and_advance() zero length is a no-op.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 lib/iov_iter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 906e9d49c487..ebb907c6393c 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -117,7 +117,7 @@ 
 #define iterate_and_advance(i, n, v, I, B, K, X) {		\
 	if (unlikely(i->count < n))				\
 		n = i->count;					\
-	if (i->count) {						\
+	if (likely(n)) {					\
 		size_t skip = i->iov_offset;			\
 		if (likely(iter_is_iovec(i))) {			\
 			const struct iovec *iov;		\