Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1363410rwb; Fri, 19 Aug 2022 02:14:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR64yBfa2DjP/Hz3Es9yU+jXPBENY7assK+f3LvF5wumtMOpL3JCkjlrv7rIP8eKgYKjzgh5 X-Received: by 2002:a63:ff24:0:b0:42a:20e7:99a5 with SMTP id k36-20020a63ff24000000b0042a20e799a5mr3914391pgi.261.1660900497700; Fri, 19 Aug 2022 02:14:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660900497; cv=none; d=google.com; s=arc-20160816; b=tG3vf+qUGODubTjtmyvHzoZzsAT39Scn5+oRdJEGf9gOIPidJHd+oBrTjNb7miiuhH MZx7tM0nxqnPWireag8U6NqYc5DKqdQkxwnOU+v1c3d5iePf528XE22Nr3eStrraMHRa +vOgSVecu1VC8sijP7MQI3Qg0J10BdBtTet7X24kYE1QuZnIrdTEAQlyAmlQXO9MjUCk z/QE/KU8MYB91nqVQ6Zmil0Pzm/AUX1cMsLW7PtHNg3JNnsqRH9UwgBj146DUkg4RQfs Sek1oRrIUPmxFMYKV8B91azzz+ot3midDYyXJnSZihrkFAyJjcKXxh3Vx7HbISpNMVmg 7aLQ== 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=p1k6Pm+SvbBY62QEofoW7g6l7h0lzojfDX5HDxLdLHU=; b=mxaI5T1VCL2TacftA15sEPn2h/MoIQ45dvUC15X3TYZt81N7D95RGkNR2AHQtsCFYT EVcMvoURKxARs2+P0fKP/3diIXLAKLvexbiMxw4bkWPZ3GRmIa5d3aYmJWPmoD/LcMSw F7wxA4j4wanlyHRzr1RcupNLTvvyajuRCbYYQG4x/oueafKw/HcxHxdpRpOpaV/RHsUv LRlh2Qyen6+OPsp2OBj9P+GUoq1wvv+cJsEkx7v6x95EoztB1dNynj6MCbOYSi4i9rLm Fne+7j0dOpkKbV305sPqJpTkCnlpgJWmWnZmjntOL6H+x5/PknvEZyLpsu+1SCysGT5a nu0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=lbnYwsbt; dkim=neutral (no key) header.i=@suse.cz header.b=55ayS2Wg; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a4-20020a170902ecc400b0016dba016f15si3584083plh.227.2022.08.19.02.14.46; Fri, 19 Aug 2022 02:14:57 -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=@suse.cz header.s=susede2_rsa header.b=lbnYwsbt; dkim=neutral (no key) header.i=@suse.cz header.b=55ayS2Wg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347632AbiHSJGt (ORCPT + 99 others); Fri, 19 Aug 2022 05:06:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347388AbiHSJGo (ORCPT ); Fri, 19 Aug 2022 05:06:44 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C38FEE6AA; Fri, 19 Aug 2022 02:06:43 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id CA5EB375E0; Fri, 19 Aug 2022 09:06:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1660900001; 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=p1k6Pm+SvbBY62QEofoW7g6l7h0lzojfDX5HDxLdLHU=; b=lbnYwsbtyrnMuUNpFxFU0guvzqLFci8KCRCMsh2j01sk4m+ej0q+grl3ZeOCvCFXwTn5UQ bKLhpV2eGfMds8MA5uOQIU0RzVsgq5yn1DnKD7RqIVKEkwevg+o7vyBa6L7neYd9NL115u PcPMCcBtrP+mV6dyWNjENbzys/AlWzo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1660900001; 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=p1k6Pm+SvbBY62QEofoW7g6l7h0lzojfDX5HDxLdLHU=; b=55ayS2WgkhIWYhOv3qj3RAq57e3GpsCPA/oxyJhMYoi/wal43reLcL/nPGDx+Remm/mjJy +1XNF3YryqEYqbAw== Received: from quack3.suse.cz (unknown [10.100.224.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 2EDED2C145; Fri, 19 Aug 2022 09:06:41 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id 95DE9A0635; Fri, 19 Aug 2022 11:06:40 +0200 (CEST) Date: Fri, 19 Aug 2022 11:06:40 +0200 From: Jan Kara To: Jiangshan Yi <13667453960@163.com> Cc: jack@suse.cz, axboe@kernel.dk, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, reiserfs-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Jiangshan Yi Subject: Re: [PATCH] fs/reiserfs: replace ternary operator with min() and min_t() Message-ID: <20220819090640.lhp5esp7mbcpu53i@quack3> References: <20220819075240.3199477-1-13667453960@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220819075240.3199477-1-13667453960@163.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-kernel@vger.kernel.org On Fri 19-08-22 15:52:40, Jiangshan Yi wrote: > 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 Thanks for the cleanup. I've added the patch to my tree. Honza > --- > 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 > -- Jan Kara SUSE Labs, CR