Skip to content

Commit 4bb1a13

Browse files
xp4ns3Al Viro
authored andcommitted
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 <[email protected]> Suggested-by: Al Viro <[email protected]> Signed-off-by: Fabio M. De Francesco <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 4309093 commit 4bb1a13

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

fs/sysv/dir.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
211211
return -EINVAL;
212212

213213
got_it:
214-
pos = page_offset(page) +
215-
(char*)de - (char*)page_address(page);
214+
pos = page_offset(page) + offset_in_page(de);
216215
lock_page(page);
217216
err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE);
218217
if (err)
@@ -236,8 +235,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
236235
int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page)
237236
{
238237
struct inode *inode = page->mapping->host;
239-
char *kaddr = (char*)page_address(page);
240-
loff_t pos = page_offset(page) + (char *)de - kaddr;
238+
loff_t pos = page_offset(page) + offset_in_page(de);
241239
int err;
242240

243241
lock_page(page);
@@ -335,8 +333,7 @@ void sysv_set_link(struct sysv_dir_entry *de, struct page *page,
335333
struct inode *inode)
336334
{
337335
struct inode *dir = page->mapping->host;
338-
loff_t pos = page_offset(page) +
339-
(char *)de-(char*)page_address(page);
336+
loff_t pos = page_offset(page) + offset_in_page(de);
340337
int err;
341338

342339
lock_page(page);

0 commit comments

Comments
 (0)