From nobody Sat Apr 18 10:53:40 2026 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 38E0FC433EF for ; Thu, 14 Jul 2022 06:33:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232359AbiGNGdq (ORCPT ); Thu, 14 Jul 2022 02:33:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbiGNGdm (ORCPT ); Thu, 14 Jul 2022 02:33:42 -0400 Received: from m12-18.163.com (m12-18.163.com [220.181.12.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 714E42ADF; Wed, 13 Jul 2022 23:33:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=y2Bvn iMhbl5jK8THTHxbQtXvRNWzTIer28MZL2NagjI=; b=MFjxR9LAZtTatjvAg+SSn 3wsJMnONJHk7V30YTydtZZTcDNUenpZ4+UEE3q+vpSF6c90QyFvluQDhnoGaR07P rd7vEnz5rN9iPrLrKhotoHTAJlprSg37YERsQahCN0VH2Jd9M0mYc5EimS+0D8cF 0zyXrlE0SONYleVCM4YawY= Received: from localhost.localdomain (unknown [111.48.58.12]) by smtp14 (Coremail) with SMTP id EsCowAAnT_K2uM9i5aWBMw--.1991S2; Thu, 14 Jul 2022 14:33:29 +0800 (CST) From: Jiangshan Yi <13667453960@163.com> To: jack@suse.com Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, Jiangshan Yi Subject: [PATCH] fs/ext2: replace ternary operator with min_t() Date: Thu, 14 Jul 2022 14:33:18 +0800 Message-Id: <20220714063318.1777139-1-13667453960@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: EsCowAAnT_K2uM9i5aWBMw--.1991S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7uFWfCr15KF1UtF1ktF4Utwb_yoW8GrykpF ykAr4xGFyrur1UX3ZrWw4DX3WxWayDKF40qrWj9r1UZr9xtw1fKFn8tFy5WF409r4xZ34v qFs09ryxJw1xWw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jxF4iUUUUU= X-Originating-IP: [111.48.58.12] X-CM-SenderInfo: bprtllyxuvjmiwq6il2tof0z/xtbBthU++11uPnbZhAAAsA Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jiangshan Yi Fix the following coccicheck warning: fs/ext2/super.c:1494: WARNING opportunity for min(). fs/ext2/super.c:1533: WARNING opportunity for min(). min_t() macro is defined in include/linux/minmax.h. It avoids multiple evaluations of the arguments when non-constant and performs strict type-checking. Signed-off-by: Jiangshan Yi --- fs/ext2/super.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/ext2/super.c b/fs/ext2/super.c index f6a19f6d9f6d..300f2f0cf566 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -1490,8 +1490,7 @@ static ssize_t ext2_quota_read(struct super_block *sb= , int type, char *data, len =3D i_size-off; toread =3D len; while (toread > 0) { - tocopy =3D sb->s_blocksize - offset < toread ? - sb->s_blocksize - offset : toread; + tocopy =3D min_t(size_t, sb->s_blocksize - offset, toread); =20 tmp_bh.b_state =3D 0; tmp_bh.b_size =3D sb->s_blocksize; @@ -1529,8 +1528,7 @@ static ssize_t ext2_quota_write(struct super_block *s= b, int type, struct buffer_head *bh; =20 while (towrite > 0) { - tocopy =3D sb->s_blocksize - offset < towrite ? - sb->s_blocksize - offset : towrite; + tocopy =3D min_t(size_t, sb->s_blocksize - offset, towrite); =20 tmp_bh.b_state =3D 0; tmp_bh.b_size =3D sb->s_blocksize; --=20 2.25.1