staging: lustre: libcfs: Use swap() in cfs_hash_bd_order()
authorAmitoj Kaur Chawla <amitoj1606@gmail.com>
Tue, 23 Feb 2016 21:42:47 +0000 (03:12 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Feb 2016 06:18:11 +0000 (22:18 -0800)
Use swap() function instead of using a temporary variable for swapping
two variables.

The Coccinelle semantic patch used to make this change is as follows:
//<smpl>
@@
type T;
T a,b,c;
@@
- a = b;
- b = c;
- c = a;
+ swap(b, c);
//<smpl>

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/libcfs/hash.c

index 5e2afe4a57f836edeb5787676bb81e09c1d2203a..8e6f9ac714a91b1008bdadce1eed7cc4fb71e5b7 100644 (file)
@@ -803,12 +803,8 @@ cfs_hash_bd_order(struct cfs_hash_bd *bd1, struct cfs_hash_bd *bd2)
        if (rc == 0) {
                bd2->bd_bucket = NULL;
 
-       } else if (rc > 0) { /* swab bd1 and bd2 */
-               struct cfs_hash_bd tmp;
-
-               tmp = *bd2;
-               *bd2 = *bd1;
-               *bd1 = tmp;
+       } else if (rc > 0) {
+               swap(*bd1, *bd2); /* swap bd1 and bd2 */
        }
 }