From ce4615dd5709638a1f26e6cd59ebf880d5b8864d Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 22 Jun 2018 23:05:49 -0400 Subject: [PATCH] libext2fs: simplify extent_fallocate() The goal_distance variable is used in only one place in the extent_fallocate() function, so set it right before it is used, and eliminate one assignment of goal_distance which is never used before it gets overwritten. Fixes-Coverity-Bug: 1307694 Signed-off-by: Theodore Ts'o --- lib/ext2fs/fallocate.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/ext2fs/fallocate.c b/lib/ext2fs/fallocate.c index 01c709a..31e47f8 100644 --- a/lib/ext2fs/fallocate.c +++ b/lib/ext2fs/fallocate.c @@ -726,7 +726,6 @@ start_again: left_adjacent = NULL; } goal = left_extent.e_pblk + (range_start - left_extent.e_lblk); - goal_distance = range_start - next; do { err = ext2fs_extent_get(handle, EXT2_EXTENT_NEXT_LEAF, @@ -749,12 +748,11 @@ start_again: range_end = right_extent.e_lblk - 1; right_adjacent = &right_extent; } + goal_distance = range_start - next; if (err != EXT2_ET_EXTENT_NO_NEXT && - goal_distance > (range_end - right_extent.e_lblk)) { + goal_distance > (range_end - right_extent.e_lblk)) goal = right_extent.e_pblk - (right_extent.e_lblk - range_start); - goal_distance = range_end - right_extent.e_lblk; - } dbg_printf("%s: ino=%d rstart=%llu rend=%llu\n", __func__, ino, range_start, range_end); @@ -779,7 +777,6 @@ start_again: left_adjacent = &left_extent; range_start = next; goal = left_extent.e_pblk + (range_start - left_extent.e_lblk); - goal_distance = range_start - next; } while (range_end < end); errout: -- 1.8.3.1