linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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()
Date: Tue, 25 Oct 2022 22:51:35 +0800 (GMT+08:00)	[thread overview]
Message-ID: <5036013e.4.1840fa09d42.Coremail.wangkailong@jari.cn> (raw)

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 <wangkailong@jari.cn>
---
 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)
-- 
2.25.1

             reply	other threads:[~2022-10-25 14:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25 14:51 wangkailong [this message]
2022-10-26  1:17 ` [PATCH] ext4: replace ternary operator with min() Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5036013e.4.1840fa09d42.Coremail.wangkailong@jari.cn \
    --to=wangkailong@jari.cn \
    --cc=adilger.kernel@dilger.ca \
    --cc=akpm@linux-foundation.org \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roman.gushchin@linux.dev \
    --cc=senozhatsky@chromium.org \
    --cc=sfrench@samba.org \
    --cc=tom@talpey.com \
    --cc=tytso@mit.edu \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).