public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] ext4: Simplify if condition
@ 2024-08-30  7:17 Jiapeng Chong
  2024-09-12  9:07 ` Jan Kara
  2024-11-07 15:12 ` Theodore Ts'o
  0 siblings, 2 replies; 3+ messages in thread
From: Jiapeng Chong @ 2024-08-30  7:17 UTC (permalink / raw)
  To: tytso; +Cc: adilger.kernel, linux-ext4, linux-kernel, Jiapeng Chong,
	Abaci Robot

The if condition !A || A && B can be simplified to !A || B.

./fs/ext4/fast_commit.c:362:21-23: WARNING !A || A && B is equivalent to !A || B.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9837
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 fs/ext4/fast_commit.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
index 326c16a4e51e..53a77172dc9f 100644
--- a/fs/ext4/fast_commit.c
+++ b/fs/ext4/fast_commit.c
@@ -357,9 +357,7 @@ void ext4_fc_mark_ineligible(struct super_block *sb, int reason, handle_t *handl
 	}
 	spin_lock(&sbi->s_fc_lock);
 	is_ineligible = ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);
-	if (has_transaction &&
-	    (!is_ineligible ||
-	     (is_ineligible && tid_gt(tid, sbi->s_fc_ineligible_tid))))
+	if (has_transaction && (!is_ineligible || tid_gt(tid, sbi->s_fc_ineligible_tid)))
 		sbi->s_fc_ineligible_tid = tid;
 	ext4_set_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);
 	spin_unlock(&sbi->s_fc_lock);
-- 
2.32.0.3.g01195cf9f


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

* Re: [PATCH -next] ext4: Simplify if condition
  2024-08-30  7:17 [PATCH -next] ext4: Simplify if condition Jiapeng Chong
@ 2024-09-12  9:07 ` Jan Kara
  2024-11-07 15:12 ` Theodore Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2024-09-12  9:07 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: tytso, adilger.kernel, linux-ext4, linux-kernel, Abaci Robot

On Fri 30-08-24 15:17:13, Jiapeng Chong wrote:
> The if condition !A || A && B can be simplified to !A || B.
> 
> ./fs/ext4/fast_commit.c:362:21-23: WARNING !A || A && B is equivalent to !A || B.
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9837
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

Looks good. Feel free to add:

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

								Honza

> ---
>  fs/ext4/fast_commit.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
> index 326c16a4e51e..53a77172dc9f 100644
> --- a/fs/ext4/fast_commit.c
> +++ b/fs/ext4/fast_commit.c
> @@ -357,9 +357,7 @@ void ext4_fc_mark_ineligible(struct super_block *sb, int reason, handle_t *handl
>  	}
>  	spin_lock(&sbi->s_fc_lock);
>  	is_ineligible = ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);
> -	if (has_transaction &&
> -	    (!is_ineligible ||
> -	     (is_ineligible && tid_gt(tid, sbi->s_fc_ineligible_tid))))
> +	if (has_transaction && (!is_ineligible || tid_gt(tid, sbi->s_fc_ineligible_tid)))
>  		sbi->s_fc_ineligible_tid = tid;
>  	ext4_set_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);
>  	spin_unlock(&sbi->s_fc_lock);
> -- 
> 2.32.0.3.g01195cf9f
> 
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH -next] ext4: Simplify if condition
  2024-08-30  7:17 [PATCH -next] ext4: Simplify if condition Jiapeng Chong
  2024-09-12  9:07 ` Jan Kara
@ 2024-11-07 15:12 ` Theodore Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2024-11-07 15:12 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: Theodore Ts'o, adilger.kernel, linux-ext4, linux-kernel,
	Abaci Robot


On Fri, 30 Aug 2024 15:17:13 +0800, Jiapeng Chong wrote:
> The if condition !A || A && B can be simplified to !A || B.
> 
> ./fs/ext4/fast_commit.c:362:21-23: WARNING !A || A && B is equivalent to !A || B.
> 
> 

Applied, thanks!

[1/1] ext4: Simplify if condition
      commit: 296eb810fa1f346f3a1eae46504459a3f81126dc

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

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

end of thread, other threads:[~2024-11-07 15:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-30  7:17 [PATCH -next] ext4: Simplify if condition Jiapeng Chong
2024-09-12  9:07 ` Jan Kara
2024-11-07 15:12 ` 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