* [PATCH] mtip32xx: replace ternary operator with min_t()
@ 2022-07-12 9:43 Jiangshan Yi
2022-07-16 12:33 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Jiangshan Yi @ 2022-07-12 9:43 UTC (permalink / raw
To: axboe; +Cc: linux-block, linux-kernel, Jiangshan Yi
From: Jiangshan Yi <yijiangshan@kylinos.cn>
Fix the following coccicheck warning:
drivers/block/mtip32xx/mtip32xx.c:2264: WARNING opportunity for min().
drivers/block/mtip32xx/mtip32xx.c:2328: WARNING opportunity for min().
drivers/block/mtip32xx/mtip32xx.c:2357: 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>
---
drivers/block/mtip32xx/mtip32xx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 27386a572ba4..ef6bc68f86a3 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2261,7 +2261,7 @@ static ssize_t mtip_hw_read_device_status(struct file *f, char __user *ubuf,
size += show_device_status(NULL, buf);
- *offset = size <= len ? size : len;
+ *offset = min_t(size_t, size, len);
size = copy_to_user(ubuf, buf, *offset);
if (size)
rv = -EFAULT;
@@ -2325,7 +2325,7 @@ static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
}
size += sprintf(&buf[size], "]\n");
- *offset = size <= len ? size : len;
+ *offset = min_t(size_t, size, len);
size = copy_to_user(ubuf, buf, *offset);
if (size)
rv = -EFAULT;
@@ -2354,7 +2354,7 @@ static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,
size += sprintf(&buf[size], "Flag-dd : [ %08lX ]\n",
dd->dd_flag);
- *offset = size <= len ? size : len;
+ *offset = min_t(size_t, size, len);
size = copy_to_user(ubuf, buf, *offset);
if (size)
rv = -EFAULT;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtip32xx: replace ternary operator with min_t()
2022-07-12 9:43 [PATCH] mtip32xx: replace ternary operator with min_t() Jiangshan Yi
@ 2022-07-16 12:33 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2022-07-16 12:33 UTC (permalink / raw
To: 13667453960; +Cc: linux-block, linux-kernel, yijiangshan
On Tue, 12 Jul 2022 17:43:50 +0800, Jiangshan Yi wrote:
> From: Jiangshan Yi <yijiangshan@kylinos.cn>
>
> Fix the following coccicheck warning:
>
> drivers/block/mtip32xx/mtip32xx.c:2264: WARNING opportunity for min().
> drivers/block/mtip32xx/mtip32xx.c:2328: WARNING opportunity for min().
> drivers/block/mtip32xx/mtip32xx.c:2357: WARNING opportunity for min().
>
> [...]
Applied, thanks!
[1/1] mtip32xx: replace ternary operator with min_t()
(no commit info)
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-16 12:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-12 9:43 [PATCH] mtip32xx: replace ternary operator with min_t() Jiangshan Yi
2022-07-16 12:33 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).