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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <669773b7-4428-43ca-ab80-d7ed1c71886c@suse.com>
Date: Sat, 28 Jun 2025 14:18:03 +0930
From: Qu Wenruo <wqu@...e.com>
To: George Hu <integral@...hlinux.org>, 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
Subject: Re: [PATCH] btrfs: replace nested usage of min & max with clamp in
 btrfs_compress_set_level()



在 2025/6/28 14:02, 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.

Can you please only touch the "level != 0" branch using clamp()?

With a not-that-short expression used in the conditional operator, I do 
not think the final result is easier to read.

Thanks,
Qu

> 
> 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);
>   }
>   
>   /*


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ