[PATCH] mtip32xx: replace ternary operator with min_t()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jiangshan Yi <yijiangshan@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 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




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux