Skip to contentSkip to conversation

fuse: use DIV_ROUND_UP helper macro for calculations

PATCH Applied Wu Bo 2 participants 3 messages May 25, 2021 – Jun 21, 2021

Subsystems (2)
lore
Share & tools
lore

Wu Bo

author
#0 lore raw

PATCH 1/1 fuse: use DIV_ROUND_UP helper macro for calculations

From: Wu Bo <[email protected]>

Replace open coded divisor calculations with the DIV_ROUND_UP kernel macro for better readability.

---
 fs/fuse/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/file.c +1 -1
index 09ef2a4..62443eb 100644
@@ -1405,7 +1405,7 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii,
 		nbytes += ret;
 
 		ret += start;
-		npages = (ret + PAGE_SIZE - 1) / PAGE_SIZE;
+		npages = DIV_ROUND_UP(ret, PAGE_SIZE);
 
 		ap->descs[ap->num_pages].offset = start;
 		fuse_page_descs_length_init(ap->descs, ap->num_pages, npages);
Signature · 1 line
1.8.3.1
author
#1 lore raw

ping ...

Quoted 24 lines · Wu Bo

From: Wu Bo <[email protected]>

Replace open coded divisor calculations with the DIV_ROUND_UP kernel macro for better readability.

---
  fs/fuse/file.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/file.c +1 -1
index 09ef2a4..62443eb 100644
@@ -1405,7 +1405,7 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii,
  		nbytes += ret;
 
  		ret += start;
-		npages = (ret + PAGE_SIZE - 1) / PAGE_SIZE;
+		npages = DIV_ROUND_UP(ret, PAGE_SIZE);
 
  		ap->descs[ap->num_pages].offset = start;
  		fuse_page_descs_length_init(ap->descs, ap->num_pages, npages);