ext4: replace ternary operator with min()
Subsystems (5)
PATCH 1/1 ext4: replace ternary operator with min()
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 <[email protected]>
--- 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(-)
fs/ext4/inline.c +1 -2
@@ -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);
fs/hpfs/name.c +1 -1
@@ -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++) {
fs/isofs/inode.c +1 -1
@@ -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)
fs/ksmbd/oplock.c +2 -2
@@ -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 )
Signature · 1 line
2.25.1
Sergey Senozhatsky
reviewerOn (22/10/25 22:51), [email protected] wrote:
[..]
Quoted 10 lines
fs/ksmbd/oplock.c +1
-1@@ -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) {/*
fs/ksmbd/oplock.c static int oplock_break(struct oplock_info *brk_opinfo, int req_op_level) · line 916
Quoted 5 lines
fs/ksmbd/oplock.c +1
-1@@ -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 );
Honestly, I don't know. My personal preference would be to keep it as is. "return min(err, 0)" is a bit unusually looking code. Just my 2 cents.