mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] btrfs: replace nested usage of min & max with clamp in btrfs_compress_set_level()
@ 2025-06-28  4:32 George Hu
  2025-06-28  4:48 ` Qu Wenruo
  0 siblings, 1 reply; 5+ messages in thread
From: George Hu @ 2025-06-28  4:32 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba
  Cc: linux-btrfs, linux-kernel, George Hu

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@archlinux.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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-06-30 16:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-28  4:32 [PATCH] btrfs: replace nested usage of min & max with clamp in btrfs_compress_set_level() George Hu
2025-06-28  4:48 ` Qu Wenruo
2025-06-28  5:21   ` [PATCH v2] " George Hu
2025-06-28  5:26     ` Qu Wenruo
2025-06-30 16:12     ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®