lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250628043235.29900-1-integral@archlinux.org>
Date: Sat, 28 Jun 2025 12:32:35 +0800
From: George Hu <integral@...hlinux.org>
To: Chris Mason <clm@...com>,
	Josef Bacik <josef@...icpanda.com>,
	David Sterba <dsterba@...e.com>
Cc: linux-btrfs@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	George Hu <integral@...hlinux.org>
Subject: [PATCH] btrfs: replace nested usage of min & max with clamp in btrfs_compress_set_level()

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.

Signed-off-by: George Hu <integral@...hlinux.org>
---
 fs/btrfs/compression.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 48d07939fee4..662736d94814 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -972,12 +972,7 @@ static int btrfs_compress_set_level(unsigned int type, int level)
 {
 	const struct btrfs_compress_op *ops = btrfs_compress_op[type];
 
-	if (level == 0)
-		level = ops->default_level;
-	else
-		level = min(max(level, ops->min_level), ops->max_level);
-
-	return level;
+	return level == 0 ? ops->default_level : clamp(level, ops->min_level, ops->max_level);
 }
 
 /*
-- 
2.50.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ