From 4bb1a1375ac33950385d17321c546aeb520ba152 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Thu, 19 Jan 2023 16:32:29 +0100 Subject: [PATCH] fs/sysv: Use the offset_in_page() helper Use the offset_in_page() helper because it is more suitable than doing explicit subtractions between pointers to directory entries and kernel virtual addresses of mapped pages. Cc: Ira Weiny Suggested-by: Al Viro Signed-off-by: Fabio M. De Francesco Signed-off-by: Al Viro --- fs/sysv/dir.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c index 16730795a621..0edd18e1d376 100644 --- a/fs/sysv/dir.c +++ b/fs/sysv/dir.c @@ -211,8 +211,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode) return -EINVAL; got_it: - pos = page_offset(page) + - (char*)de - (char*)page_address(page); + pos = page_offset(page) + offset_in_page(de); lock_page(page); err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE); if (err) @@ -236,8 +235,7 @@ out_unlock: int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page) { struct inode *inode = page->mapping->host; - char *kaddr = (char*)page_address(page); - loff_t pos = page_offset(page) + (char *)de - kaddr; + loff_t pos = page_offset(page) + offset_in_page(de); int err; lock_page(page); @@ -335,8 +333,7 @@ void sysv_set_link(struct sysv_dir_entry *de, struct page *page, struct inode *inode) { struct inode *dir = page->mapping->host; - loff_t pos = page_offset(page) + - (char *)de-(char*)page_address(page); + loff_t pos = page_offset(page) + offset_in_page(de); int err; lock_page(page);