diff options
Diffstat (limited to 'include/linux/uio.h')
-rw-r--r-- | include/linux/uio.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/include/linux/uio.h b/include/linux/uio.h index e2231e47cec1..d54985e0705e 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h | |||
@@ -94,8 +94,20 @@ static inline size_t iov_iter_count(struct iov_iter *i) | |||
94 | return i->count; | 94 | return i->count; |
95 | } | 95 | } |
96 | 96 | ||
97 | static inline void iov_iter_truncate(struct iov_iter *i, size_t count) | 97 | /* |
98 | * Cap the iov_iter by given limit; note that the second argument is | ||
99 | * *not* the new size - it's upper limit for such. Passing it a value | ||
100 | * greater than the amount of data in iov_iter is fine - it'll just do | ||
101 | * nothing in that case. | ||
102 | */ | ||
103 | static inline void iov_iter_truncate(struct iov_iter *i, u64 count) | ||
98 | { | 104 | { |
105 | /* | ||
106 | * count doesn't have to fit in size_t - comparison extends both | ||
107 | * operands to u64 here and any value that would be truncated by | ||
108 | * conversion in assignement is by definition greater than all | ||
109 | * values of size_t, including old i->count. | ||
110 | */ | ||
99 | if (i->count > count) | 111 | if (i->count > count) |
100 | i->count = count; | 112 | i->count = count; |
101 | } | 113 | } |