From: George Hu <integral@archlinux.org>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
George Hu <integral@archlinux.org>
Subject: [PATCH] btrfs: replace nested usage of min & max with clamp in btrfs_compress_set_level()
Date: Sat, 28 Jun 2025 12:32:35 +0800 [thread overview]
Message-ID: <20250628043235.29900-1-integral@archlinux.org> (raw)
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
next reply other threads:[~2025-06-28 4:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-28 4:32 George Hu [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250628043235.29900-1-integral@archlinux.org \
--to=integral@archlinux.org \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®