]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: replace nested usage of min & max with clamp in btrfs_compress_set_level()
authorGeorge Hu <integral@archlinux.org>
Sat, 28 Jun 2025 05:21:30 +0000 (13:21 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 21:58:05 +0000 (23:58 +0200)
Refactor the btrfs_compress_set_level() function by replacing the
nested usage of min() and max() macro with clamp() to simplify the
code and improve readability.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: George Hu <integral@archlinux.org>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c

index a4934eb1ecdc99382e420a3fd2e1316b1f630d7d..6d3161bc778142ede87d3cf117c7caeb0ab35f51 100644 (file)
@@ -975,7 +975,7 @@ static int btrfs_compress_set_level(unsigned int type, int level)
        if (level == 0)
                level = ops->default_level;
        else
-               level = min(max(level, ops->min_level), ops->max_level);
+               level = clamp(level, ops->min_level, ops->max_level);
 
        return level;
 }