diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2022-12-14 04:26:27 +0300 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2023-05-29 12:03:19 +0300 |
commit | 86008392695bd7a910b9d1452c828f9c7d1a6a1f (patch) | |
tree | 642292780981cf0409c89a8ab140db6c6570bb37 /fs/ext2 | |
parent | 8f1dca19b1e11785f42e70da796942154f63aef9 (diff) | |
download | linux-86008392695bd7a910b9d1452c828f9c7d1a6a1f.tar.xz |
ext2: use offset_in_page() instead of open-coding it as subtraction
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Reviewed-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Tested-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext2')
-rw-r--r-- | fs/ext2/dir.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c index a3c77ea5a7de..5141ec6a6b51 100644 --- a/fs/ext2/dir.c +++ b/fs/ext2/dir.c @@ -240,7 +240,7 @@ ext2_validate_entry(char *base, unsigned offset, unsigned mask) break; p = ext2_next_entry(p); } - return (char *)p - base; + return offset_in_page(p); } static inline void ext2_set_de_type(ext2_dirent *de, struct inode *inode) @@ -465,8 +465,7 @@ int ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de, struct page *page, void *page_addr, struct inode *inode, bool update_times) { - loff_t pos = page_offset(page) + - (char *) de - (char *) page_addr; + loff_t pos = page_offset(page) + offset_in_page(de); unsigned len = ext2_rec_len_from_disk(de->rec_len); int err; @@ -556,8 +555,7 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode) return -EINVAL; got_it: - pos = page_offset(page) + - (char *)de - (char *)page_addr; + pos = page_offset(page) + offset_in_page(de); err = ext2_prepare_chunk(page, pos, rec_len); if (err) goto out_unlock; @@ -594,8 +592,8 @@ int ext2_delete_entry (struct ext2_dir_entry_2 *dir, struct page *page, char *kaddr) { struct inode *inode = page->mapping->host; - unsigned from = ((char*)dir - kaddr) & ~(ext2_chunk_size(inode)-1); - unsigned to = ((char *)dir - kaddr) + + unsigned from = offset_in_page(dir) & ~(ext2_chunk_size(inode)-1); + unsigned to = offset_in_page(dir) + ext2_rec_len_from_disk(dir->rec_len); loff_t pos; ext2_dirent * pde = NULL; @@ -612,7 +610,7 @@ int ext2_delete_entry (struct ext2_dir_entry_2 *dir, struct page *page, de = ext2_next_entry(de); } if (pde) - from = (char *)pde - kaddr; + from = offset_in_page(pde); pos = page_offset(page) + from; lock_page(page); err = ext2_prepare_chunk(page, pos, to - from); |