]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
libxfs: remove dangerous casting between cache_node and xfs_buf
authorDarrick J. Wong <darrick.wong@oracle.com>
Sun, 1 Mar 2020 17:34:11 +0000 (12:34 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Sun, 1 Mar 2020 17:34:11 +0000 (12:34 -0500)
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>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/rdwr.c

index f92c7db93c67bc2e3faab041721be3c7c7fe6539..68e8e014b25717f0219531dcadb02659ba0a6d71 100644 (file)
@@ -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);