Re: [PATCH -next] ext4: Simplify if condition

From: Jan Kara
Date: Thu Sep 12 2024 - 05:07:39 EST


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@xxxxxxxxxxxxxxxxx>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9837
> Signed-off-by: Jiapeng Chong <jiapeng.chong@xxxxxxxxxxxxxxxxx>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

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@xxxxxxxx>
SUSE Labs, CR