mm: shrinker: use min() to improve shrinker_debugfs_scan_write()
authorThorsten Blum <thorsten.blum@toblux.com>
Tue, 20 Aug 2024 04:22:55 +0000 (06:22 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 4 Sep 2024 04:15:40 +0000 (21:15 -0700)
Use the min() macro to simplify the shrinker_debugfs_scan_write() function
and improve its readability.

Link: https://lkml.kernel.org/r/20240820042254.99115-2-thorsten.blum@toblux.com
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/shrinker_debug.c

index 12ea5486a3e959e299217fc6c1dcef634ae9a291..4a85b94d12ce2fef467645a8b699bc325571cc7b 100644 (file)
@@ -114,7 +114,7 @@ static ssize_t shrinker_debugfs_scan_write(struct file *file,
        int nid;
        char kbuf[72];
 
-       read_len = size < (sizeof(kbuf) - 1) ? size : (sizeof(kbuf) - 1);
+       read_len = min(size, sizeof(kbuf) - 1);
        if (copy_from_user(kbuf, buf, read_len))
                return -EFAULT;
        kbuf[read_len] = '\0';