diff mbox series

[21/26] libxfs: remove dangerous casting between cache_node and xfs_buf

Message ID 158293311167.1549542.8858385148278085051.stgit@magnolia (mailing list archive)
State Accepted
Headers show
Series xfsprogs: refactor buffer function names | expand

Commit Message

Darrick J. Wong Feb. 28, 2020, 11:38 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Get rid of all the dangerous casting between cache_node and xfs_buf
since we can use container_of now.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 libxfs/rdwr.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index f92c7db9..68e8e014 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -301,8 +301,9 @@  libxfs_bhash(cache_key_t key, unsigned int hashsize, unsigned int hashshift)
 static int
 libxfs_bcompare(struct cache_node *node, cache_key_t key)
 {
-	struct xfs_buf	*bp = (struct xfs_buf *)node;
-	struct xfs_bufkey *bkey = (struct xfs_bufkey *)key;
+	struct xfs_buf		*bp = container_of(node, struct xfs_buf,
+						   b_node);
+	struct xfs_bufkey	*bkey = (struct xfs_bufkey *)key;
 
 	if (bp->b_target->dev == bkey->buftarg->dev &&
 	    bp->b_bn == bkey->blkno) {
@@ -1052,7 +1053,8 @@  static void
 libxfs_brelse(
 	struct cache_node	*node)
 {
-	struct xfs_buf		*bp = (struct xfs_buf *)node;
+	struct xfs_buf		*bp = container_of(node, struct xfs_buf,
+						   b_node);
 
 	if (!bp)
 		return;
@@ -1117,7 +1119,8 @@  static int
 libxfs_bflush(
 	struct cache_node	*node)
 {
-	struct xfs_buf		*bp = (struct xfs_buf *)node;
+	struct xfs_buf		*bp = container_of(node, struct xfs_buf,
+						   b_node);
 
 	if (!bp->b_error && bp->b_flags & LIBXFS_B_DIRTY)
 		return libxfs_bwrite(bp);