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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>

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@xxxxxxxxxx>
Reviewed-by: Christoph Hellwig <hch@xxxxxx>
---
 libxfs/rdwr.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)


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);




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux