Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp916473rwd; Thu, 8 Jun 2023 09:22:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6JuZjEcsRFM/HbRpppvYa5/yxoZhl+11XV1gSqIn6tuVPixl6Yo318iSZJA1vg47ZavdOH X-Received: by 2002:a17:90a:f297:b0:253:3975:7a37 with SMTP id fs23-20020a17090af29700b0025339757a37mr3184982pjb.9.1686241333018; Thu, 08 Jun 2023 09:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686241333; cv=none; d=google.com; s=arc-20160816; b=njOgUvGA43hDxu5WJUWBbnTu5vb0FGtVIl6DymQ8NZuhg9QiD3vdbXitX7Qr4flhuH gJFJkNsV7GoJGuxab8sMTBx9xjLZUz6hXTnHV79nQ+mIO2/hKNBsBp/jaYPhZeIVNzSr dGu7pMQSme3vCddE/eYv/a7buDRoUx+s3lR+pxlS50sXvctUKNqDnQ6ZFUUQgeVNfG2M HomCVXwWSkwyupPL7VCxU6dhB2a0HmJg0hcOVFwbi4SHmTjPXqbWr3Piyq10OW/KhDkn nUxbSwKiMIQEOICh7p/a77rkS63VYw3sGrRQl6hjf9bFsUcQXCFg6Gr5R7m9gxY9Cy/g AVmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=Civ667UQ8fwevWftFe2wG8O2eACHxqqQ5lCSI9TWYew=; b=ggfhtOyZg1M1yLhaZH6PtLVdMIilQM4vnF/bpnUDGUsTNrhJNnfo1SQbcO40smp9J8 dJjmmWNFn3mhlUrAlSeq3zCgT43eGWFoGLFFWLPXNR6iovft5SmVqgGMc4D2OYM/Q8Ln 93GIrWmAUTbYr8tGul3j/MrD8EMZ6No1N/QqCxwj5U2l9/9c8fNlnVSD2zoJ2e68KXw4 6DJcGhqCgf8B3XIjcTVwAxrjZD7tu0A4EidrdnQksCHiEBqRALjMPEykZhMm5+q9xVu4 tIXoHF1UesB7KEE1MUiGZk23PQpvfgvBpa40GYGLlq9uPaXBnKvNEURqD2ivlRj1K5OD ggoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=G47wYF+u; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=8oMJG4pq; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 1-20020a17090a034100b00256917c7851si2931178pjf.107.2023.06.08.09.21.53; Thu, 08 Jun 2023 09:22:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=G47wYF+u; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=8oMJG4pq; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233653AbjFHQVf (ORCPT + 99 others); Thu, 8 Jun 2023 12:21:35 -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> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@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