mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ext4: Fix traditional comparison using max/min method
@ 2023-05-29  7:09 Lu Hongfei
  2023-06-08 16:21 ` Jan Kara
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lu Hongfei @ 2023-05-29  7:09 UTC (permalink / raw)
  To: Theodore Ts'o, Andreas Dilger, open list:EXT4 FILE SYSTEM, open list
  Cc: opensource.kernel, luhongfei

It would be better to replace the traditional ternary conditional
operator with max()/min()

Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
---
 fs/ext4/balloc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
 mode change 100644 => 100755 fs/ext4/balloc.c

diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index c1edde817be8..82124045d187
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -111,10 +111,8 @@ static unsigned ext4_num_overhead_clusters(struct super_block *sb,
 	itbl_blk_start = ext4_inode_table(sb, gdp);
 	itbl_blk_end = itbl_blk_start + sbi->s_itb_per_group - 1;
 	if (itbl_blk_start <= end && itbl_blk_end >= start) {
-		itbl_blk_start = itbl_blk_start >= start ?
-			itbl_blk_start : start;
-		itbl_blk_end = itbl_blk_end <= end ?
-			itbl_blk_end : end;
+		itbl_blk_start = max(itbl_blk_start, start);
+		itbl_blk_end = min(itbl_blk_end, end);
 
 		itbl_cluster_start = EXT4_B2C(sbi, itbl_blk_start - start);
 		itbl_cluster_end = EXT4_B2C(sbi, itbl_blk_end - start);
-- 
2.39.0


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

* Re: [PATCH] ext4: Fix traditional comparison using max/min method
  2023-05-29  7:09 [PATCH] ext4: Fix traditional comparison using max/min method Lu Hongfei
@ 2023-06-08 16:21 ` Jan Kara
  2023-06-09  1:48 ` Kemeng Shi
  2023-10-06 18:06 ` Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Kara @ 2023-06-08 16:21 UTC (permalink / raw)
  To: Lu Hongfei
  Cc: Theodore Ts'o, Andreas Dilger, open list:EXT4 FILE SYSTEM,
	open list, opensource.kernel

On Mon 29-05-23 15:09:30, Lu Hongfei wrote:
> It would be better to replace the traditional ternary conditional
> operator with max()/min()
> 
> Signed-off-by: Lu Hongfei <luhongfei@vivo.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ext4/balloc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>  mode change 100644 => 100755 fs/ext4/balloc.c
> 
> diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
> index c1edde817be8..82124045d187
> --- a/fs/ext4/balloc.c
> +++ b/fs/ext4/balloc.c
> @@ -111,10 +111,8 @@ static unsigned ext4_num_overhead_clusters(struct super_block *sb,
>  	itbl_blk_start = ext4_inode_table(sb, gdp);
>  	itbl_blk_end = itbl_blk_start + sbi->s_itb_per_group - 1;
>  	if (itbl_blk_start <= end && itbl_blk_end >= start) {
> -		itbl_blk_start = itbl_blk_start >= start ?
> -			itbl_blk_start : start;
> -		itbl_blk_end = itbl_blk_end <= end ?
> -			itbl_blk_end : end;
> +		itbl_blk_start = max(itbl_blk_start, start);
> +		itbl_blk_end = min(itbl_blk_end, end);
>  
>  		itbl_cluster_start = EXT4_B2C(sbi, itbl_blk_start - start);
>  		itbl_cluster_end = EXT4_B2C(sbi, itbl_blk_end - start);
> -- 
> 2.39.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH] ext4: Fix traditional comparison using max/min method
  2023-05-29  7:09 [PATCH] ext4: Fix traditional comparison using max/min method Lu Hongfei
  2023-06-08 16:21 ` Jan Kara
@ 2023-06-09  1:48 ` Kemeng Shi
  2023-10-06 18:06 ` Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Kemeng Shi @ 2023-06-09  1:48 UTC (permalink / raw)
  To: Lu Hongfei, Theodore Ts'o, Andreas Dilger,
	open list:EXT4 FILE SYSTEM, open list
  Cc: opensource.kernel



on 5/29/2023 3:09 PM, Lu Hongfei wrote:
> It would be better to replace the traditional ternary conditional
> operator with max()/min()
> 
> Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
> ---
>  fs/ext4/balloc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>  mode change 100644 => 100755 fs/ext4/balloc.c
> 
> diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
> index c1edde817be8..82124045d187
> --- a/fs/ext4/balloc.c
> +++ b/fs/ext4/balloc.c
> @@ -111,10 +111,8 @@ static unsigned ext4_num_overhead_clusters(struct super_block *sb,
>  	itbl_blk_start = ext4_inode_table(sb, gdp);
>  	itbl_blk_end = itbl_blk_start + sbi->s_itb_per_group - 1;
>  	if (itbl_blk_start <= end && itbl_blk_end >= start) {
> -		itbl_blk_start = itbl_blk_start >= start ?
> -			itbl_blk_start : start;
> -		itbl_blk_end = itbl_blk_end <= end ?
> -			itbl_blk_end : end;
> +		itbl_blk_start = max(itbl_blk_start, start);
> +		itbl_blk_end = min(itbl_blk_end, end);
>  
>  		itbl_cluster_start = EXT4_B2C(sbi, itbl_blk_start - start);
>  		itbl_cluster_end = EXT4_B2C(sbi, itbl_blk_end - start);
> 

Thanks for the improve, Looks good. Feel free to add:

Reviewed-by: Kemeng Shi <shikemeng@huaweicloud.com>

-- 
Best wishes
Kemeng Shi


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

* Re: [PATCH] ext4: Fix traditional comparison using max/min method
  2023-05-29  7:09 [PATCH] ext4: Fix traditional comparison using max/min method Lu Hongfei
  2023-06-08 16:21 ` Jan Kara
  2023-06-09  1:48 ` Kemeng Shi
@ 2023-10-06 18:06 ` Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2023-10-06 18:06 UTC (permalink / raw)
  To: Andreas Dilger, linux-ext4, linux-kernel, Lu Hongfei
  Cc: Theodore Ts'o, opensource.kernel


On Mon, 29 May 2023 15:09:30 +0800, Lu Hongfei wrote:
> It would be better to replace the traditional ternary conditional
> operator with max()/min()
> 
> 

Applied, thanks!

[1/1] ext4: Fix traditional comparison using max/min method
      commit: a8c1eb77edfc92a64788dad70fedf9277cbafe76

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>

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

end of thread, other threads:[~2023-10-06 18:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-29  7:09 [PATCH] ext4: Fix traditional comparison using max/min method Lu Hongfei
2023-06-08 16:21 ` Jan Kara
2023-06-09  1:48 ` Kemeng Shi
2023-10-06 18:06 ` Theodore Ts'o

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®