]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
btrfs: Remove unnecessary casts in btrfs_read_root_item
authorYueHaibing <yuehaibing@huawei.com>
Wed, 20 Feb 2019 12:32:02 +0000 (12:32 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 Feb 2019 13:19:23 +0000 (14:19 +0100)
There is a messy cast here:
min_t(int, len, (int)sizeof(*item)));

min_t() should normally cast to unsigned.  It's not possible for "len"
to be negative, but if it were then we definitely wouldn't want to pass
negatives to read_extent_buffer().  Also there is an extra cast.

This patch shouldn't affect runtime, it's just a clean up.

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/root-tree.c

index 65bda0682928babb4671a154fbad886badbc3e7f..0d2b957ca3a31f4aa44ccfd7c0fd43f006c5922a 100644 (file)
@@ -21,12 +21,12 @@ static void btrfs_read_root_item(struct extent_buffer *eb, int slot,
                                struct btrfs_root_item *item)
 {
        uuid_le uuid;
-       int len;
+       u32 len;
        int need_reset = 0;
 
        len = btrfs_item_size_nr(eb, slot);
        read_extent_buffer(eb, item, btrfs_item_ptr_offset(eb, slot),
-                       min_t(int, len, (int)sizeof(*item)));
+                          min_t(u32, len, sizeof(*item)));
        if (len < sizeof(*item))
                need_reset = 1;
        if (!need_reset && btrfs_root_generation(item)