Commit 88ee2df7 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Chinner

xfs: return a void pointer from xfs_buf_offset

This avoids all kinds of unessecary casts in an envrionment like Linux where
we can assume that pointer arithmetics are support on void pointers.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent fc51c2b5
...@@ -44,8 +44,7 @@ xfs_icluster_size_fsb( ...@@ -44,8 +44,7 @@ xfs_icluster_size_fsb(
static inline struct xfs_dinode * static inline struct xfs_dinode *
xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o) xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)
{ {
return (struct xfs_dinode *) return xfs_buf_offset(b, o << (mp)->m_sb.sb_inodelog);
(xfs_buf_offset(b, o << (mp)->m_sb.sb_inodelog));
} }
/* /*
......
...@@ -46,8 +46,7 @@ xfs_inobp_check( ...@@ -46,8 +46,7 @@ xfs_inobp_check(
j = mp->m_inode_cluster_size >> mp->m_sb.sb_inodelog; j = mp->m_inode_cluster_size >> mp->m_sb.sb_inodelog;
for (i = 0; i < j; i++) { for (i = 0; i < j; i++) {
dip = (xfs_dinode_t *)xfs_buf_offset(bp, dip = xfs_buf_offset(bp, i * mp->m_sb.sb_inodesize);
i * mp->m_sb.sb_inodesize);
if (!dip->di_next_unlinked) { if (!dip->di_next_unlinked) {
xfs_alert(mp, xfs_alert(mp,
"Detected bogus zero next_unlinked field in inode %d buffer 0x%llx.", "Detected bogus zero next_unlinked field in inode %d buffer 0x%llx.",
...@@ -86,8 +85,7 @@ xfs_inode_buf_verify( ...@@ -86,8 +85,7 @@ xfs_inode_buf_verify(
int di_ok; int di_ok;
xfs_dinode_t *dip; xfs_dinode_t *dip;
dip = (struct xfs_dinode *)xfs_buf_offset(bp, dip = xfs_buf_offset(bp, (i << mp->m_sb.sb_inodelog));
(i << mp->m_sb.sb_inodelog));
di_ok = dip->di_magic == cpu_to_be16(XFS_DINODE_MAGIC) && di_ok = dip->di_magic == cpu_to_be16(XFS_DINODE_MAGIC) &&
XFS_DINODE_GOOD_VERSION(dip->di_version); XFS_DINODE_GOOD_VERSION(dip->di_version);
if (unlikely(XFS_TEST_ERROR(!di_ok, mp, if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
...@@ -186,7 +184,7 @@ xfs_imap_to_bp( ...@@ -186,7 +184,7 @@ xfs_imap_to_bp(
} }
*bpp = bp; *bpp = bp;
*dipp = (struct xfs_dinode *)xfs_buf_offset(bp, imap->im_boffset); *dipp = xfs_buf_offset(bp, imap->im_boffset);
return 0; return 0;
} }
......
...@@ -1419,9 +1419,9 @@ xfs_buf_submit_wait( ...@@ -1419,9 +1419,9 @@ xfs_buf_submit_wait(
return error; return error;
} }
xfs_caddr_t void *
xfs_buf_offset( xfs_buf_offset(
xfs_buf_t *bp, struct xfs_buf *bp,
size_t offset) size_t offset)
{ {
struct page *page; struct page *page;
...@@ -1431,7 +1431,7 @@ xfs_buf_offset( ...@@ -1431,7 +1431,7 @@ xfs_buf_offset(
offset += bp->b_offset; offset += bp->b_offset;
page = bp->b_pages[offset >> PAGE_SHIFT]; page = bp->b_pages[offset >> PAGE_SHIFT];
return (xfs_caddr_t)page_address(page) + (offset & (PAGE_SIZE-1)); return page_address(page) + (offset & (PAGE_SIZE-1));
} }
/* /*
......
...@@ -299,7 +299,7 @@ extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *, ...@@ -299,7 +299,7 @@ extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *,
xfs_buf_iomove((bp), (off), (len), NULL, XBRW_ZERO) xfs_buf_iomove((bp), (off), (len), NULL, XBRW_ZERO)
/* Buffer Utility Routines */ /* Buffer Utility Routines */
extern xfs_caddr_t xfs_buf_offset(xfs_buf_t *, size_t); extern void *xfs_buf_offset(struct xfs_buf *, size_t);
/* Delayed Write Buffer Routines */ /* Delayed Write Buffer Routines */
extern bool xfs_buf_delwri_queue(struct xfs_buf *, struct list_head *); extern bool xfs_buf_delwri_queue(struct xfs_buf *, struct list_head *);
......
...@@ -3464,7 +3464,7 @@ xfs_iflush_int( ...@@ -3464,7 +3464,7 @@ xfs_iflush_int(
ASSERT(ip->i_d.di_version > 1); ASSERT(ip->i_d.di_version > 1);
/* set *dip = inode's place in the buffer */ /* set *dip = inode's place in the buffer */
dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset); dip = xfs_buf_offset(bp, ip->i_imap.im_boffset);
if (XFS_TEST_ERROR(dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC), if (XFS_TEST_ERROR(dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC),
mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) { mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) {
......
...@@ -1789,8 +1789,7 @@ xlog_recover_do_inode_buffer( ...@@ -1789,8 +1789,7 @@ xlog_recover_do_inode_buffer(
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
buffer_nextp = (xfs_agino_t *)xfs_buf_offset(bp, buffer_nextp = xfs_buf_offset(bp, next_unlinked_offset);
next_unlinked_offset);
*buffer_nextp = *logged_nextp; *buffer_nextp = *logged_nextp;
/* /*
...@@ -1798,7 +1797,7 @@ xlog_recover_do_inode_buffer( ...@@ -1798,7 +1797,7 @@ xlog_recover_do_inode_buffer(
* have to leave the inode in a consistent state for whoever * have to leave the inode in a consistent state for whoever
* reads it next.... * reads it next....
*/ */
xfs_dinode_calc_crc(mp, (struct xfs_dinode *) xfs_dinode_calc_crc(mp,
xfs_buf_offset(bp, i * mp->m_sb.sb_inodesize)); xfs_buf_offset(bp, i * mp->m_sb.sb_inodesize));
} }
...@@ -2546,7 +2545,7 @@ xlog_recover_inode_pass2( ...@@ -2546,7 +2545,7 @@ xlog_recover_inode_pass2(
goto out_release; goto out_release;
} }
ASSERT(in_f->ilf_fields & XFS_ILOG_CORE); ASSERT(in_f->ilf_fields & XFS_ILOG_CORE);
dip = (xfs_dinode_t *)xfs_buf_offset(bp, in_f->ilf_boffset); dip = xfs_buf_offset(bp, in_f->ilf_boffset);
/* /*
* Make sure the place we're flushing out to really looks * Make sure the place we're flushing out to really looks
...@@ -2885,7 +2884,7 @@ xlog_recover_dquot_pass2( ...@@ -2885,7 +2884,7 @@ xlog_recover_dquot_pass2(
return error; return error;
ASSERT(bp); ASSERT(bp);
ddq = (xfs_disk_dquot_t *)xfs_buf_offset(bp, dq_f->qlf_boffset); ddq = xfs_buf_offset(bp, dq_f->qlf_boffset);
/* /*
* If the dquot has an LSN in it, recover the dquot only if it's less * If the dquot has an LSN in it, recover the dquot only if it's less
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment