Skip to content

Commit 43d631b

Browse files
tobluxpaulmckrcu
authored andcommitted
kcsan: Use min() to fix Coccinelle warning
Fixes the following Coccinelle/coccicheck warning reported by minmax.cocci: WARNING opportunity for min() Use const size_t instead of int for the result of min(). Compile-tested with CONFIG_KCSAN=y. Reviewed-by: Marco Elver <[email protected]> Signed-off-by: Thorsten Blum <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 8400291 commit 43d631b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/kcsan/debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ debugfs_write(struct file *file, const char __user *buf, size_t count, loff_t *o
225225
{
226226
char kbuf[KSYM_NAME_LEN];
227227
char *arg;
228-
int read_len = count < (sizeof(kbuf) - 1) ? count : (sizeof(kbuf) - 1);
228+
const size_t read_len = min(count, sizeof(kbuf) - 1);
229229

230230
if (copy_from_user(kbuf, buf, read_len))
231231
return -EFAULT;

0 commit comments

Comments
 (0)