diff options
author | Jiangshan Yi <yijiangshan@kylinos.cn> | 2022-08-17 10:59:28 +0800 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2022-11-29 16:10:49 -0500 |
commit | 66267814ba0ee0732c69ca87eb1fd6eb63bf0d5f (patch) | |
tree | 204a4c8a28740257bd95d86ff1e209d31587a65b /fs/ext4/extents.c | |
parent | 318cdc822c63b6e2befcfdc2088378ae6fa18def (diff) | |
download | lwn-66267814ba0ee0732c69ca87eb1fd6eb63bf0d5f.tar.gz lwn-66267814ba0ee0732c69ca87eb1fd6eb63bf0d5f.zip |
fs/ext4: replace ternary operator with min()/max() and min_t()
Fix the following coccicheck warning:
fs/ext4/inline.c:183: WARNING opportunity for min().
fs/ext4/extents.c:2631: WARNING opportunity for max().
fs/ext4/extents.c:2632: WARNING opportunity for min().
fs/ext4/extents.c:5559: WARNING opportunity for max().
fs/ext4/super.c:6908: WARNING opportunity for min().
min()/max() 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.
Reported-by: kernel test robot <lkp@intel.com>
Suggested-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Link: https://lore.kernel.org/r/20220817025928.612851-1-13667453960@163.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 6c399a8b22b3..ec008278d970 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -2635,9 +2635,8 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode, unwritten, ex_ee_len); path[depth].p_ext = ex; - a = ex_ee_block > start ? ex_ee_block : start; - b = ex_ee_block+ex_ee_len - 1 < end ? - ex_ee_block+ex_ee_len - 1 : end; + a = max(ex_ee_block, start); + b = min(ex_ee_block + ex_ee_len - 1, end); ext_debug(inode, " border %u:%u\n", a, b); @@ -5567,8 +5566,7 @@ static int ext4_insert_range(struct file *file, loff_t offset, loff_t len) * ee_start_lblk to shift extents */ ret = ext4_ext_shift_extents(inode, handle, - ee_start_lblk > offset_lblk ? ee_start_lblk : offset_lblk, - len_lblk, SHIFT_RIGHT); + max(ee_start_lblk, offset_lblk), len_lblk, SHIFT_RIGHT); up_write(&EXT4_I(inode)->i_data_sem); if (IS_SYNC(inode)) |