[PATCH] gfs2: Use min_t() to improve code

Qianfeng Rong posted 1 patch 1 month, 2 weeks ago
fs/gfs2/file.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
[PATCH] gfs2: Use min_t() to improve code
Posted by Qianfeng Rong 1 month, 2 weeks ago
Use min_t() to reduce the code in gfs2_page_mkwrite() and improve its
readability.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
 fs/gfs2/file.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index bc67fa058c84..b54746299c5a 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -448,10 +448,7 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf)
 	file_update_time(vmf->vma->vm_file);
 
 	/* folio is wholly or partially inside EOF */
-	if (size - pos < folio_size(folio))
-		length = size - pos;
-	else
-		length = folio_size(folio);
+	length = min_t(size_t, size - pos, folio_size(folio));
 
 	gfs2_size_hint(vmf->vma->vm_file, pos, length);
 
-- 
2.34.1