[06/10] ext4: replace the traditional ternary conditional operator with with max()/min()

Message ID 20230721171007.2065423-7-shikemeng@huaweicloud.com
State New
Headers
Series A few fixes and cleanups to mballoc |

Commit Message

Kemeng Shi July 21, 2023, 5:10 p.m. UTC
  Replace the traditional ternary conditional operator with with max()/min()

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
 fs/ext4/mballoc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
  

Comments

Ritesh Harjani (IBM) July 21, 2023, 3:44 p.m. UTC | #1
Kemeng Shi <shikemeng@huaweicloud.com> writes:

> Replace the traditional ternary conditional operator with with max()/min()

sure. 

>
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
>  fs/ext4/mballoc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Looks good to me, feel free to add: 
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

-ritesh

>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 78160bf5b533..412d335583fe 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -6699,8 +6699,7 @@ __releases(ext4_group_lock_ptr(sb, e4b->bd_group))
>  	void *bitmap;
>  
>  	bitmap = e4b->bd_bitmap;
> -	start = (e4b->bd_info->bb_first_free > start) ?
> -		e4b->bd_info->bb_first_free : start;
> +	start = max(e4b->bd_info->bb_first_free, start);
>  	count = 0;
>  	free_count = 0;
>  
> @@ -6917,8 +6916,7 @@ ext4_mballoc_query_range(
>  
>  	ext4_lock_group(sb, group);
>  
> -	start = (e4b.bd_info->bb_first_free > start) ?
> -		e4b.bd_info->bb_first_free : start;
> +	start = max(e4b.bd_info->bb_first_free, start);
>  	if (end >= EXT4_CLUSTERS_PER_GROUP(sb))
>  		end = EXT4_CLUSTERS_PER_GROUP(sb) - 1;
>  
> -- 
> 2.30.0
  

Patch

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 78160bf5b533..412d335583fe 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -6699,8 +6699,7 @@  __releases(ext4_group_lock_ptr(sb, e4b->bd_group))
 	void *bitmap;
 
 	bitmap = e4b->bd_bitmap;
-	start = (e4b->bd_info->bb_first_free > start) ?
-		e4b->bd_info->bb_first_free : start;
+	start = max(e4b->bd_info->bb_first_free, start);
 	count = 0;
 	free_count = 0;
 
@@ -6917,8 +6916,7 @@  ext4_mballoc_query_range(
 
 	ext4_lock_group(sb, group);
 
-	start = (e4b.bd_info->bb_first_free > start) ?
-		e4b.bd_info->bb_first_free : start;
+	start = max(e4b.bd_info->bb_first_free, start);
 	if (end >= EXT4_CLUSTERS_PER_GROUP(sb))
 		end = EXT4_CLUSTERS_PER_GROUP(sb) - 1;