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: 10857 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1060838wru; Tue, 25 Oct 2022 08:12:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ANNW/PnP78+NUXJ7p+z9eRiLs0uHa+WaQnajxw6UTLM13jrZeovpU5Z+Lp0Om77CK99Bo X-Received: by 2002:a63:145d:0:b0:44b:f115:f90f with SMTP id 29-20020a63145d000000b0044bf115f90fmr33520733pgu.157.1666710739872; Tue, 25 Oct 2022 08:12:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666710739; cv=none; d=google.com; s=arc-20160816; b=HPKCdPYIhhJRFKk2UQ0iBKQnKWjwgAAMJz3i5j8pizclk5ogwPwGk12XS7m2gfmtVa kf0r9XbR3ocg0I9yAbZReF4BnnBz02cAJzshlB8ckuvtLUAzfyBu1A66p3GGv2gluO/F uPN1Iao/egVPCoktnR7UdppfjGoXHLjDfOHzabP4SBPtVjbAFxI5J6J2kxbLE0DZrbeL taGk+qH8/kxr6ZX9XuLVR39LyWZ46K+PsPYroWUgEH1mPdSmOFD1mPHGRhre1xZRebup Np30N429oZF00xxxCic5h0FJPdn85JUDmBm8D8mxiQ3A/nEeEupFGjUOJvh2FOXZ//21 H+QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:mime-version :content-transfer-encoding:subject:cc:to:from:date; bh=dOHXKpLftXhLHdcSJw2Axjq0vNc/tcBkkzAn1dGdjw4=; b=GvsYULDJ2VRvMscw8Vp0eEtJMj2FGfQzW2HBeTMmOQ5JgCl0ccxonbIjStGHAzUAfc rAfpgLfUnOStckZc++MaNliTuf6sf0OVdSEKNePl3GwjDSxcQD0U1ENu6pD/LWt4MUdf 9/ZKZdWa4jr7h7hHzRU1jRtxNRb/V46fM8/1hIph5y2SnDLnqdelV+n6vnE/1XLr4kBU wke5rENs+Ovc/O9XuIMYPpjY6ZTYUbdURenzwbs1ykhshQjZbj+S1sWojZaigc+Io4no 41Zh8BHZGSyGLrDEi1xXVAAjvTVbdjy8/6vwtQRGWfAm9H9YAUwegFVk2aibqGMNzwgd LlMQ== ARC-Authentication-Results: i=1; mx.google.com; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o2-20020a056a0015c200b005631f695371si3526922pfu.127.2022.10.25.08.12.01; Tue, 25 Oct 2022 08:12:19 -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; 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 S232403AbiJYO61 (ORCPT + 99 others); Tue, 25 Oct 2022 10:58:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232282AbiJYO60 (ORCPT ); Tue, 25 Oct 2022 10:58:26 -0400 Received: from jari.cn (unknown [218.92.28.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 518161A9913 for ; Tue, 25 Oct 2022 07:58:18 -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= X-Spam-Status: No, score=2.2 required=5.0 tests=BAYES_00,RCVD_IN_PBL,RDNS_NONE, T_SPF_HELO_PERMERROR,T_SPF_PERMERROR,XPRIO autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747672880370777043?= X-GMAIL-MSGID: =?utf-8?q?1747672880370777043?= 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)