lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 12 Jul 2022 17:43:50 +0800
From:   Jiangshan Yi <13667453960@....com>
To:     axboe@...nel.dk
Cc:     linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
        Jiangshan Yi <yijiangshan@...inos.cn>
Subject: [PATCH] mtip32xx: replace ternary operator with min_t()

From: Jiangshan Yi <yijiangshan@...inos.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@...inos.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ