Skip to content

Commit

Permalink
fs/jfs: replace ternary operator with min_t()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jiangshan Yi authored and Dave Kleikamp committed Oct 18, 2022
1 parent 898f706 commit 73c6da3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions fs/jfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,7 @@ static ssize_t jfs_quota_read(struct super_block *sb, int type, char *data,
len = i_size-off;
toread = len;
while (toread > 0) {
tocopy = sb->s_blocksize - offset < toread ?
sb->s_blocksize - offset : toread;
tocopy = min_t(size_t, sb->s_blocksize - offset, toread);

tmp_bh.b_state = 0;
tmp_bh.b_size = i_blocksize(inode);
Expand Down Expand Up @@ -785,8 +784,7 @@ static ssize_t jfs_quota_write(struct super_block *sb, int type,

inode_lock(inode);
while (towrite > 0) {
tocopy = sb->s_blocksize - offset < towrite ?
sb->s_blocksize - offset : towrite;
tocopy = min_t(size_t, sb->s_blocksize - offset, towrite);

tmp_bh.b_state = 0;
tmp_bh.b_size = i_blocksize(inode);
Expand Down

0 comments on commit 73c6da3

Please sign in to comment.