All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kcsan: Use min() to fix Coccinelle warning
@ 2024-06-23 22:06 Thorsten Blum
  2024-06-24  7:02 ` Marco Elver
  0 siblings, 1 reply; 6+ messages in thread
From: Thorsten Blum @ 2024-06-23 22:06 UTC (permalink / raw)
  To: elver, dvyukov; +Cc: kasan-dev, linux-kernel, Thorsten Blum

Fixes the following Coccinelle/coccicheck warning reported by
minmax.cocci:

	WARNING opportunity for min()

Use size_t instead of int for the result of min().

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 kernel/kcsan/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/kcsan/debugfs.c b/kernel/kcsan/debugfs.c
index 1d1d1b0e4248..11b891fe6f7a 100644
--- a/kernel/kcsan/debugfs.c
+++ b/kernel/kcsan/debugfs.c
@@ -225,7 +225,7 @@ debugfs_write(struct file *file, const char __user *buf, size_t count, loff_t *o
 {
 	char kbuf[KSYM_NAME_LEN];
 	char *arg;
-	int read_len = count < (sizeof(kbuf) - 1) ? count : (sizeof(kbuf) - 1);
+	size_t read_len = min(count, (sizeof(kbuf) - 1));
 
 	if (copy_from_user(kbuf, buf, read_len))
 		return -EFAULT;
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-06-28 15:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-23 22:06 [PATCH] kcsan: Use min() to fix Coccinelle warning Thorsten Blum
2024-06-24  7:02 ` Marco Elver
2024-06-24  8:00   ` Thorsten Blum
2024-06-24  8:44     ` Marco Elver
2024-06-28 14:51   ` David Laight
2024-06-28 15:03     ` Marco Elver

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.