* [PATCH] fs/jfs: replace ternary operator with min_t()
@ 2022-07-14 2:56 Jiangshan Yi
2022-10-17 20:03 ` Dave Kleikamp
0 siblings, 1 reply; 2+ messages in thread
From: Jiangshan Yi @ 2022-07-14 2:56 UTC (permalink / raw)
To: shaggy; +Cc: jfs-discussion, linux-kernel, Jiangshan Yi
From: Jiangshan Yi <yijiangshan@kylinos.cn>
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>
---
fs/jfs/super.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 85d4f44f2ac4..d2f82cb7db1b 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -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);
@@ -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);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fs/jfs: replace ternary operator with min_t()
2022-07-14 2:56 [PATCH] fs/jfs: replace ternary operator with min_t() Jiangshan Yi
@ 2022-10-17 20:03 ` Dave Kleikamp
0 siblings, 0 replies; 2+ messages in thread
From: Dave Kleikamp @ 2022-10-17 20:03 UTC (permalink / raw)
To: Jiangshan Yi; +Cc: jfs-discussion, linux-kernel, Jiangshan Yi
Catching up on old patches. Sorry this took so long. Looks good to me.
I'll push it to mainline.
Thanks,
Shaggy
On 7/13/22 9:56PM, Jiangshan Yi wrote:
> From: Jiangshan Yi <yijiangshan@kylinos.cn>
>
> 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>
> ---
> fs/jfs/super.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/jfs/super.c b/fs/jfs/super.c
> index 85d4f44f2ac4..d2f82cb7db1b 100644
> --- a/fs/jfs/super.c
> +++ b/fs/jfs/super.c
> @@ -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);
> @@ -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);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-17 20:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-14 2:56 [PATCH] fs/jfs: replace ternary operator with min_t() Jiangshan Yi
2022-10-17 20:03 ` Dave Kleikamp
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.