From: Amitoj Kaur Chawla Date: Mon, 2 Jan 2017 00:19:16 +0000 (-0500) Subject: LU-4423 libcfs: Use swap() in cfs_hash_bd_order() X-Git-Tag: 2.9.52~10 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=8a13ffb4a1eafff18cb891fdc812afaf09136f29 LU-4423 libcfs: Use swap() in cfs_hash_bd_order() 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 Change-Id: I19aa52fe4e05fed2e03c1d8515731a5ce01b3d09 Signed-off-by: Greg Kroah-Hartman Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/24576 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Dmitry Eremin --- diff --git a/libcfs/libcfs/hash.c b/libcfs/libcfs/hash.c index 61fffb3..bae84df 100644 --- a/libcfs/libcfs/hash.c +++ b/libcfs/libcfs/hash.c @@ -798,12 +798,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); /* swab bd1 and bd2 */ } }