Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1331768rwb; Fri, 19 Aug 2022 01:32:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR5/SlMfJENUFom0IXg8KUz7vu5QDN9yp+C2EQRmnecOOgNnAPDkd3kTM+pKGc9nmlRR+m9n X-Received: by 2002:a63:5359:0:b0:41d:b5a6:23c5 with SMTP id t25-20020a635359000000b0041db5a623c5mr5470406pgl.128.1660897966265; Fri, 19 Aug 2022 01:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660897966; cv=none; d=google.com; s=arc-20160816; b=jAdCuM7aOY9fbpAEaub1VGi9IJwgUAGzsLplslxyRYI9Pyw/EWq+GG4y1K861TAZ7Z 9HDdy7gv5IJ5r2Tu3xHUyySP6CbCisgmKwVbIbt45jwkojSAGAMtjgn2hR4JfFDPGZfc Gj+NaIR8NrkgKoarIlSXUZnikGqwQslAqU9ytshPoXsuEAlSrS64hjf4V3LdkUJm6sk4 mo7zGktDn6gLCRniq6uiXnLUOGLBd642jIvKzOteOaF4gbJecV4/83BpuLFYwSlt5qWX AlMYMteUOFQIzFEBImPTKskPhktPNXCxPqk/VT7/vhBCF/ZpH6zhtbKwMI3HNR2qcKu7 4l2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=vIxxMCB3Kbo1suOSCWxUTAkIasvejZxcJgO9tarL/Ns=; b=tfS9L4sFLHHrd9J7wsQ94/rD1yR7eVKRFSk7ACFLfyz4aQdAJ6GELcYnpNS8l80xVR nLOz0mwrzTVLjbCyoXEle+ll3SOGqSRm9+E8duFOoKD859fL4u1HoaMpPP7btQJ14fhE x5aC/KK4CmAwKc8YIilWTLzZN1d8hWQBHjyb1pX+EzrFPdG/M2Ff2knZAycpWwL/2jhL zsXgg3+AxVD1BGyqyTGYUxbpZz66husN6jrVq9vdhz3nh7h0dIRQfVfiUFiH18zLjuBM vxURhcD6XC6aBUMALq1O7ml1XYncg2bxJlBkX/PlTsbqIgC7dqAWVDAxKigkP4kWiPYp t1Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=GbqO1B4z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g132-20020a636b8a000000b0041bf0b57ad8si3165906pgc.807.2022.08.19.01.32.35; Fri, 19 Aug 2022 01:32:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@163.com header.s=s110527 header.b=GbqO1B4z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347149AbiHSHx6 (ORCPT + 99 others); Fri, 19 Aug 2022 03:53:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345865AbiHSHxy (ORCPT ); Fri, 19 Aug 2022 03:53:54 -0400 Received: from mail-m972.mail.163.com (mail-m972.mail.163.com [123.126.97.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CD36995E4C; Fri, 19 Aug 2022 00:53:50 -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=vIxxM CB3Kbo1suOSCWxUTAkIasvejZxcJgO9tarL/Ns=; b=GbqO1B4zTYyyEDPrv6g8m n57zMF3zeanLvOykEigbrMOPHAUhwfQQp/hYJ5I/vMRKnewxnXoIr3erRFi/BW/t VK0u0FqIL9ShetV+CUXbvWxylh6+DogXN9S3iAnLRSs7jL3tQ9ITka7aeARKoHRe kw0ZoP9kP+pmZX1yOgZLC0= Received: from localhost.localdomain (unknown [116.128.244.169]) by smtp2 (Coremail) with SMTP id GtxpCgCXi+dXQf9i0q+CWg--.44783S2; Fri, 19 Aug 2022 15:52:58 +0800 (CST) From: Jiangshan Yi <13667453960@163.com> To: jack@suse.cz, axboe@kernel.dk Cc: viro@zeniv.linux.org.uk, akpm@linux-foundation.org, reiserfs-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Jiangshan Yi Subject: [PATCH] fs/reiserfs: replace ternary operator with min() and min_t() Date: Fri, 19 Aug 2022 15:52:40 +0800 Message-Id: <20220819075240.3199477-1-13667453960@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: GtxpCgCXi+dXQf9i0q+CWg--.44783S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxAr4rXFWfur1UKF47WF4UJwb_yoW5WryfpF 4xAr18KFWDGryDWFn7Zwn8Aw1Sq3sxJa1jqrWkZrWIva93tw1fJr4fKry3KFW8trZ3Xw1S qr4kKr1Fy34rJw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UCPfLUUUUU= X-Originating-IP: [116.128.244.169] X-CM-SenderInfo: bprtllyxuvjmiwq6il2tof0z/1tbiyAVg+1p7HaIJdgABs2 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,FROM_LOCAL_DIGITS,FROM_LOCAL_HEX,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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-kernel@vger.kernel.org From: Jiangshan Yi Fix the following coccicheck warning: fs/reiserfs/prints.c:459: WARNING opportunity for min(). fs/reiserfs/resize.c:100: WARNING opportunity for min(). fs/reiserfs/super.c:2508: WARNING opportunity for min(). fs/reiserfs/super.c:2557: WARNING opportunity for min(). min() and 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/reiserfs/prints.c | 2 +- fs/reiserfs/resize.c | 2 +- fs/reiserfs/super.c | 7 ++----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/reiserfs/prints.c b/fs/reiserfs/prints.c index 30319dc33c18..84a194b77f19 100644 --- a/fs/reiserfs/prints.c +++ b/fs/reiserfs/prints.c @@ -456,7 +456,7 @@ static int print_internal(struct buffer_head *bh, int first, int last) to = B_NR_ITEMS(bh); } else { from = first; - to = last < B_NR_ITEMS(bh) ? last : B_NR_ITEMS(bh); + to = min_t(int, last, B_NR_ITEMS(bh)); } reiserfs_printk("INTERNAL NODE (%ld) contains %z\n", bh->b_blocknr, bh); diff --git a/fs/reiserfs/resize.c b/fs/reiserfs/resize.c index 8096c74c38ac..7b498a0d060b 100644 --- a/fs/reiserfs/resize.c +++ b/fs/reiserfs/resize.c @@ -97,7 +97,7 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new) * using the copy_size var below allows this code to work for * both shrinking and expanding the FS. */ - copy_size = bmap_nr_new < bmap_nr ? bmap_nr_new : bmap_nr; + copy_size = min(bmap_nr_new, bmap_nr); copy_size = copy_size * sizeof(struct reiserfs_list_bitmap_node *); for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) { diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index c88cd2ce0665..da1e72494e30 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -2504,9 +2504,7 @@ static ssize_t reiserfs_quota_read(struct super_block *sb, int type, char *data, len = i_size - off; toread = len; while (toread > 0) { - tocopy = - sb->s_blocksize - offset < - toread ? sb->s_blocksize - offset : toread; + tocopy = min_t(unsigned long, sb->s_blocksize - offset, toread); tmp_bh.b_state = 0; /* * Quota files are without tails so we can safely @@ -2554,8 +2552,7 @@ static ssize_t reiserfs_quota_write(struct super_block *sb, int type, return -EIO; } while (towrite > 0) { - tocopy = sb->s_blocksize - offset < towrite ? - sb->s_blocksize - offset : towrite; + tocopy = min_t(unsigned long, sb->s_blocksize - offset, towrite); tmp_bh.b_state = 0; reiserfs_write_lock(sb); err = reiserfs_get_block(inode, blk, &tmp_bh, GET_BLOCK_CREATE); -- 2.25.1 No virus found Checked by Hillstone Network AntiVirus