From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AC1CC7EE29 for ; Thu, 8 Jun 2023 16:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233741AbjFHQVh (ORCPT ); Thu, 8 Jun 2023 12:21:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233578AbjFHQVe (ORCPT ); Thu, 8 Jun 2023 12:21:34 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EDC611A; Thu, 8 Jun 2023 09:21:33 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4AE9421A77; Thu, 8 Jun 2023 16:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1686241292; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Civ667UQ8fwevWftFe2wG8O2eACHxqqQ5lCSI9TWYew=; b=G47wYF+u6AAVM2Sk8k+YW082RJjORT0h5pE9BcdFNOzg+ItjMRdqsOy+UOGZq9ydDSEwvg J/gzdnHC0zzAMfYcs9fZPobRhucEpId8nGQ/HxQBgwzZGJ77nxIToOyQq53iBVGwpHUW8d e8YXN/RqdOcEAjDqMX0XdhBjFta9/AM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1686241292; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Civ667UQ8fwevWftFe2wG8O2eACHxqqQ5lCSI9TWYew=; b=8oMJG4pqt/sf9ulFNcM63hCkr5TkAYlUe4nrtcfo4T+uyiWLYkbvJIGoMRlL+mRoxvOZz3 Otqv2L1NCZyzScDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3DB5C138E6; Thu, 8 Jun 2023 16:21:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id zZsNDwwAgmTNMgAAMHmgww (envelope-from ); Thu, 08 Jun 2023 16:21:32 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id C5895A0749; Thu, 8 Jun 2023 18:21:31 +0200 (CEST) Date: Thu, 8 Jun 2023 18:21:31 +0200 From: Jan Kara To: Lu Hongfei Cc: Theodore Ts'o , Andreas Dilger , "open list:EXT4 FILE SYSTEM" , open list , opensource.kernel@vivo.com Subject: Re: [PATCH] ext4: Fix traditional comparison using max/min method Message-ID: <20230608162131.kduwoemmbeowmfg4@quack3> References: <20230529070930.37949-1-luhongfei@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230529070930.37949-1-luhongfei@vivo.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Looks good. Feel free to add: Reviewed-by: Jan Kara 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 SUSE Labs, CR