staging: lustre: libcfs: Use swap() in cfs_hash_bd_order()

Author: Amitoj Kaur Chawla <amitoj1606@gmail.com>

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:
//
@@
type T;
T a,b,c;
@@
- a = b;
- b = c;
- c = a;
+ swap(b, c);
//

Signed-off-by: Amitoj Kaur Chawla 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/staging/lustre/lustre/libcfs/hash.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
 
diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c
index 5e2afe4..8e6f9ac 100644
--- a/drivers/staging/lustre/lustre/libcfs/hash.c
+++ b/drivers/staging/lustre/lustre/libcfs/hash.c
@@ -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 */
 	}
 }
BtrLinux
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.