From: Theodore Ts'o Date: Sat, 23 Jun 2018 03:05:49 +0000 (-0400) Subject: libext2fs: simplify extent_fallocate() X-Git-Tag: v1.44.3-rc1~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce4615dd5709638a1f26e6cd59ebf880d5b8864d;p=thirdparty%2Fe2fsprogs.git 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 --- diff --git a/lib/ext2fs/fallocate.c b/lib/ext2fs/fallocate.c index 01c709a94..31e47f8de 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: