]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: remove err variable from btrfs_get_extent
authorNikolay Borisov <nborisov@suse.com>
Mon, 3 Aug 2020 09:58:46 +0000 (12:58 +0300)
committerDavid Sterba <dsterba@suse.com>
Wed, 7 Oct 2020 10:06:57 +0000 (12:06 +0200)
commit47526118af1c85294bddc47f66d53de13992bcb9
treea06a537dde32ffd33d70507ab0d1922405311109
parentf5e8043f9a8c629687bf0dc3ff04a48c45d3511b
btrfs: remove err variable from btrfs_get_extent

There's no practical reason too use 'err' as a variable to convey
errors. In fact it's value is either set explicitly in the beginning of
the function or it simply takes the value of 'ret'. Not conforming to
the usual pattern of having ret be the only variable used to convey
errors makes the code more error prone to bugs. In fact one such bug
was introduced by a6e10077a9d5 ("btrfs: inode: Verify inode mode toi
avoid NULL pointer dereference") by assigning the error value to 'ret'
and not 'err'.

Let's fix that issue and make the function less tricky by leaving only
ret to convey error values.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c