diff options
author | David Sterba <dsterba@suse.com> | 2021-07-26 14:15:26 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2021-08-23 13:19:03 +0200 |
commit | 214cc184321743327c84c4a13ad08d088dfb3c4a (patch) | |
tree | cd0d581c411f8c12f6c1140fdf16ee434c4f8a32 /fs/btrfs/super.c | |
parent | btrfs: simplify data stripe calculation helpers (diff) | |
download | linux-214cc184321743327c84c4a13ad08d088dfb3c4a.tar.xz linux-214cc184321743327c84c4a13ad08d088dfb3c4a.zip |
btrfs: constify and cleanup variables in comparators
Comparators just read the data and thus get const parameters. This
should be also preserved by the local variables, update all comparators
passed to sort or bsearch.
Cleanups:
- unnecessary casts are dropped
- btrfs_cmp_device_free_bytes is cleaned up to follow the common pattern
and 'inline' is dropped as the function address is taken
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r-- | fs/btrfs/super.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index d07b18b2b250..35ff142ad242 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2096,16 +2096,15 @@ restore: } /* Used to sort the devices by max_avail(descending sort) */ -static inline int btrfs_cmp_device_free_bytes(const void *dev_info1, - const void *dev_info2) +static int btrfs_cmp_device_free_bytes(const void *a, const void *b) { - if (((struct btrfs_device_info *)dev_info1)->max_avail > - ((struct btrfs_device_info *)dev_info2)->max_avail) + const struct btrfs_device_info *dev_info1 = a; + const struct btrfs_device_info *dev_info2 = b; + + if (dev_info1->max_avail > dev_info2->max_avail) return -1; - else if (((struct btrfs_device_info *)dev_info1)->max_avail < - ((struct btrfs_device_info *)dev_info2)->max_avail) + else if (dev_info1->max_avail < dev_info2->max_avail) return 1; - else return 0; } |