Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs/jfs: replace ternary operator with min_t()

Fix the following coccicheck warning:

fs/jfs/super.c:748: WARNING opportunity for min().
fs/jfs/super.c:788: WARNING opportunity for min().

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.

Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>

authored by

Jiangshan Yi and committed by
Dave Kleikamp
73c6da32 898f7066

+2 -4
+2 -4
fs/jfs/super.c
··· 745 745 len = i_size-off; 746 746 toread = len; 747 747 while (toread > 0) { 748 - tocopy = sb->s_blocksize - offset < toread ? 749 - sb->s_blocksize - offset : toread; 748 + tocopy = min_t(size_t, sb->s_blocksize - offset, toread); 750 749 751 750 tmp_bh.b_state = 0; 752 751 tmp_bh.b_size = i_blocksize(inode); ··· 784 785 785 786 inode_lock(inode); 786 787 while (towrite > 0) { 787 - tocopy = sb->s_blocksize - offset < towrite ? 788 - sb->s_blocksize - offset : towrite; 788 + tocopy = min_t(size_t, sb->s_blocksize - offset, towrite); 789 789 790 790 tmp_bh.b_state = 0; 791 791 tmp_bh.b_size = i_blocksize(inode);