]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_attr_leaf: use swap macro in xfs_attr3_leaf_rebalance
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)
committerEric Sandeen <sandeen@redhat.com>
Fri, 5 Oct 2018 02:36:09 +0000 (21:36 -0500)
Source kernel commit: 1d5bebbafc73d82e5af003cdd2bf8ee5741cd1df

Make use of the swap macro and remove some unnecessary variables.
This makes the code easier to read and maintain. Also, reduces the
stack usage.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/libxfs_priv.h
libxfs/xfs_attr_leaf.c

index 2f2ca06f1bb18a4712b95975cd24b7c40755852d..da050abada2dda1803b54e6687460af9722c49c9 100644 (file)
@@ -252,6 +252,13 @@ div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder)
 #define max_t(type,x,y) \
        ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
 
+/**
+ * swap - swap values of @a and @b
+ * @a: first value
+ * @b: second value
+ */
+#define swap(a, b) \
+       do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
 
 #define __round_mask(x, y) ((__typeof__(x))((y)-1))
 #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
index abb158b26c765176cb6035bc6f9564f061b945c9..30b6990b80d5f0ccd0fd81c2b4d466a5c98e402d 100644 (file)
@@ -1561,17 +1561,10 @@ xfs_attr3_leaf_rebalance(
         */
        swap = 0;
        if (xfs_attr3_leaf_order(blk1->bp, &ichdr1, blk2->bp, &ichdr2)) {
-               struct xfs_da_state_blk *tmp_blk;
-               struct xfs_attr3_icleaf_hdr tmp_ichdr;
+               swap(blk1, blk2);
 
-               tmp_blk = blk1;
-               blk1 = blk2;
-               blk2 = tmp_blk;
-
-               /* struct copies to swap them rather than reconverting */
-               tmp_ichdr = ichdr1;
-               ichdr1 = ichdr2;
-               ichdr2 = tmp_ichdr;
+               /* swap structures rather than reconverting them */
+               swap(ichdr1, ichdr2);
 
                leaf1 = blk1->bp->b_addr;
                leaf2 = blk2->bp->b_addr;