diff mbox series

mm: shrinker: Use min() to improve shrinker_debugfs_scan_write()

Message ID 20240820042254.99115-2-thorsten.blum@toblux.com (mailing list archive)
State New
Headers show
Series mm: shrinker: Use min() to improve shrinker_debugfs_scan_write() | expand

Commit Message

Thorsten Blum Aug. 20, 2024, 4:22 a.m. UTC
Use the min() macro to simplify the shrinker_debugfs_scan_write()
function and improve its readability.

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

Comments

Muchun Song Aug. 21, 2024, 2:25 a.m. UTC | #1
> On Aug 20, 2024, at 12:22, Thorsten Blum <thorsten.blum@toblux.com> wrote:
> 
> Use the min() macro to simplify the shrinker_debugfs_scan_write()
> function and improve its readability.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>

Reviewed-by: Muchun Song <muchun.song@linux.dev>

Thanks.
diff mbox series

Patch

diff --git a/mm/shrinker_debug.c b/mm/shrinker_debug.c
index 12ea5486a3e9..4a85b94d12ce 100644
--- a/mm/shrinker_debug.c
+++ b/mm/shrinker_debug.c
@@ -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';