From patchwork Tue Oct 25 14:51:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KaiLong Wang X-Patchwork-Id: 13019427 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 BBDA6ECDFA1 for ; Tue, 25 Oct 2022 15:02:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229543AbiJYPCF (ORCPT ); Tue, 25 Oct 2022 11:02:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231349AbiJYPCE (ORCPT ); Tue, 25 Oct 2022 11:02:04 -0400 X-Greylist: delayed 224 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 25 Oct 2022 08:02:03 PDT Received: from jari.cn (unknown [218.92.28.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C0FA219E910; Tue, 25 Oct 2022 08:02:03 -0700 (PDT) Received: by ajax-webmail-localhost.localdomain (Coremail) ; Tue, 25 Oct 2022 22:51:35 +0800 (GMT+08:00) X-Originating-IP: [182.148.15.254] Date: Tue, 25 Oct 2022 22:51:35 +0800 (GMT+08:00) X-CM-HeaderCharset: UTF-8 From: wangkailong@jari.cn To: tytso@mit.edu, adilger.kernel@dilger.ca, linkinjeon@kernel.org, sfrench@samba.org, senozhatsky@chromium.org, tom@talpey.com Cc: roman.gushchin@linux.dev, akpm@linux-foundation.org, willy@infradead.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-cifs@vger.kernel.org Subject: [PATCH] ext4: replace ternary operator with min() X-Priority: 3 X-Mailer: Coremail Webmail Server Version XT6.0.1 build 20210329(c53f3fee) Copyright (c) 2002-2022 www.mailtech.cn mispb-4e503810-ca60-4ec8-a188-7102c18937cf-zhkzyfz.cn MIME-Version: 1.0 Message-ID: <5036013e.4.1840fa09d42.Coremail.wangkailong@jari.cn> X-Coremail-Locale: zh_CN X-CM-TRANSID: AQAAfwCnu+H491djhgQAAA--.1W X-CM-SenderInfo: 5zdqwypdlo00nj6mt2flof0/1tbiAQAQB2FEYxtGOgADs0 X-Coremail-Antispam: 1Ur529EdanIXcx71UUUUU7IcSsGvfJ3iIAIbVAYjsxI4VWxJw CS07vEb4IE77IF4wCS07vE1I0E4x80FVAKz4kxMIAIbVAFxVCaYxvI4VCIwcAKzIAtYxBI daVFxhVjvjDU= Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Fix the following coccicheck warning: fs/ext4/inline.c:183: WARNING opportunity for min() fs/isofs/inode.c:1153: WARNING opportunity for min() fs/ksmbd/oplock.c:882: WARNING opportunity for min() fs/ksmbd/oplock.c:916: WARNING opportunity for min() fs/hpfs/name.c:79: WARNING opportunity for min() Signed-off-by: KaiLong Wang --- fs/ext4/inline.c | 3 +-- fs/hpfs/name.c | 2 +- fs/isofs/inode.c | 2 +- fs/ksmbd/oplock.c | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index a4fbe825694b..19481f32ddfc 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -180,8 +180,7 @@ static int ext4_read_inline_data(struct inode *inode, void *buffer, BUG_ON(len > EXT4_I(inode)->i_inline_size); - cp_len = len < EXT4_MIN_INLINE_DATA_SIZE ? - len : EXT4_MIN_INLINE_DATA_SIZE; + cp_len = min(len, EXT4_MIN_INLINE_DATA_SIZE); raw_inode = ext4_raw_inode(iloc); memcpy(buffer, (void *)(raw_inode->i_block), cp_len); diff --git a/fs/hpfs/name.c b/fs/hpfs/name.c index ef7ba77f36b8..ca6160a6d6f9 100644 --- a/fs/hpfs/name.c +++ b/fs/hpfs/name.c @@ -76,7 +76,7 @@ int hpfs_compare_names(struct super_block *s, const unsigned char *n1, unsigned l1, const unsigned char *n2, unsigned l2, int last) { - unsigned l = l1 < l2 ? l1 : l2; + unsigned l = min(l1, l2); unsigned i; if (last) return -1; for (i = 0; i < l; i++) { diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index df9d70588b60..e8c1cad04bd2 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c @@ -1150,7 +1150,7 @@ static int isofs_get_block(struct inode *inode, sector_t iblock, } ret = isofs_get_blocks(inode, iblock, &bh_result, 1); - return ret < 0 ? ret : 0; + return min(ret, 0); } static int isofs_bmap(struct inode *inode, sector_t block) diff --git a/fs/ksmbd/oplock.c b/fs/ksmbd/oplock.c index d7d47b82451d..94ec8d02d877 100644 --- a/fs/ksmbd/oplock.c +++ b/fs/ksmbd/oplock.c @@ -879,7 +879,7 @@ static int oplock_break(struct oplock_info *brk_opinfo, int req_op_level) err = oplock_break_pending(brk_opinfo, req_op_level); if (err) - return err < 0 ? err : 0; + return min(err, 0); if (brk_opinfo->open_trunc) { /* @@ -913,7 +913,7 @@ static int oplock_break(struct oplock_info *brk_opinfo, int req_op_level) } else { err = oplock_break_pending(brk_opinfo, req_op_level); if (err) - return err < 0 ? err : 0; + return min(err, 0); if (brk_opinfo->level == SMB2_OPLOCK_LEVEL_BATCH || brk_opinfo->level == SMB2_OPLOCK_LEVEL_EXCLUSIVE)