Skip to content

Commit 49694d1

Browse files
Christoph HellwigDarrick J. Wong
authored andcommitted
iomap: remove the length variable in iomap_seek_hole
The length variable is rather pointless given that it can be trivially deduced from offset and size. Also the initial calculation can lead to KASAN warnings. Signed-off-by: Christoph Hellwig <[email protected]> Reported-by: Leizhen (ThunderTown) <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]>
1 parent 3ac1d42 commit 49694d1

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

fs/iomap/seek.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,20 @@ loff_t
3535
iomap_seek_hole(struct inode *inode, loff_t offset, const struct iomap_ops *ops)
3636
{
3737
loff_t size = i_size_read(inode);
38-
loff_t length = size - offset;
3938
loff_t ret;
4039

4140
/* Nothing to be found before or beyond the end of the file. */
4241
if (offset < 0 || offset >= size)
4342
return -ENXIO;
4443

45-
while (length > 0) {
46-
ret = iomap_apply(inode, offset, length, IOMAP_REPORT, ops,
47-
&offset, iomap_seek_hole_actor);
44+
while (offset < size) {
45+
ret = iomap_apply(inode, offset, size - offset, IOMAP_REPORT,
46+
ops, &offset, iomap_seek_hole_actor);
4847
if (ret < 0)
4948
return ret;
5049
if (ret == 0)
5150
break;
52-
5351
offset += ret;
54-
length -= ret;
5552
}
5653

5754
return offset;

0 commit comments

Comments
 (0)