Skip to content

Commit

Permalink
xfs: Fix uninitialized variable in xfs_reflink_reserve_cow_range()
Browse files Browse the repository at this point in the history
with gcc 4.1.2:

    fs/xfs/xfs_reflink.c: In function xfs_reflink_reserve_cow_range:
    fs/xfs/xfs_reflink.c:327: warning: error may be used uninitialized in this function

Indeed, if "count" is zero, the function will return an uninitialized
error value.

While "count" is unlikely to be zero, this function is called through
the public iomap API. Hence fix this by preinitializing error to zero.

Fixes: 2a06705 ("xfs: create delalloc extents in CoW fork")
Signed-off-by: Geert Uytterhoeven <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Dave Chinner <[email protected]>
  • Loading branch information
geertu authored and dchinner committed Oct 20, 2016
1 parent 1d55a4b commit 1be7f9b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/xfs/xfs_reflink.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ xfs_reflink_reserve_cow_range(
struct xfs_mount *mp = ip->i_mount;
xfs_fileoff_t offset_fsb, end_fsb;
bool skipped = false;
int error;
int error = 0;

trace_xfs_reflink_reserve_cow_range(ip, offset, count);

Expand Down

0 comments on commit 1be7f9b

Please sign in to comment.