[PATCH] mm: shrinker: Use min() to improve shrinker_debugfs_scan_write()

Thorsten Blum posted 1 patch 1 year, 5 months ago
mm/shrinker_debug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] mm: shrinker: Use min() to improve shrinker_debugfs_scan_write()
Posted by Thorsten Blum 1 year, 5 months ago
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(-)

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';
-- 
2.46.0
Re: [PATCH] mm: shrinker: Use min() to improve shrinker_debugfs_scan_write()
Posted by Muchun Song 1 year, 5 months ago

> 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.