* [PATCH v3 1/3] staging: lustre: libcfs: Use swap() in cfs_hash_bd_order()
2016-02-23 21:42 [PATCH v3 0/3] staging: lustre: libcfs: Use swap() and do some cleanups Amitoj Kaur Chawla
@ 2016-02-23 21:42 ` Amitoj Kaur Chawla
2016-02-23 21:43 ` [PATCH v3 3/3] staging: lustre: libcfs: Remove comparison with zero Amitoj Kaur Chawla
2016-02-23 21:43 ` [PATCH v3 2/3] staging: lustre: libcfs: Remove unnecessary braces Amitoj Kaur Chawla
2 siblings, 0 replies; 4+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-23 21:42 UTC (permalink / raw)
To: outreachy-kernel
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>
---
Changes in v3:
-Corrected spelling in comment
Changes in v2:
-Divided one patch into a series
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 */
}
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 0/3] staging: lustre: libcfs: Use swap() and do some cleanups
@ 2016-02-23 21:42 Amitoj Kaur Chawla
2016-02-23 21:42 ` [PATCH v3 1/3] staging: lustre: libcfs: Use swap() in cfs_hash_bd_order() Amitoj Kaur Chawla
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-23 21:42 UTC (permalink / raw)
To: outreachy-kernel
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>
Additionally, cleanup if-else statement block.
Amitoj Kaur Chawla (3):
staging: lustre: libcfs: Use swap() in cfs_hash_bd_order()
staging: lustre: libcfs: Remove unnecessary braces
staging: lustre: libcfs: Remove comparison with zero
Changes in v3:
-In Patch 1/3 corrected spelling in a comment.
Changes in v2:
-Divided one patch into a series.
drivers/staging/lustre/lustre/libcfs/hash.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 3/3] staging: lustre: libcfs: Remove comparison with zero
2016-02-23 21:42 [PATCH v3 0/3] staging: lustre: libcfs: Use swap() and do some cleanups Amitoj Kaur Chawla
2016-02-23 21:42 ` [PATCH v3 1/3] staging: lustre: libcfs: Use swap() in cfs_hash_bd_order() Amitoj Kaur Chawla
@ 2016-02-23 21:43 ` Amitoj Kaur Chawla
2016-02-23 21:43 ` [PATCH v3 2/3] staging: lustre: libcfs: Remove unnecessary braces Amitoj Kaur Chawla
2 siblings, 0 replies; 4+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-23 21:43 UTC (permalink / raw)
To: outreachy-kernel
Replace comparison with zero with ! operator.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
Changes in v3:
-None
Changes in v2:
-Divided one patch into a series.
drivers/staging/lustre/lustre/libcfs/hash.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c
index fa0d23c..f60feb3 100644
--- a/drivers/staging/lustre/lustre/libcfs/hash.c
+++ b/drivers/staging/lustre/lustre/libcfs/hash.c
@@ -800,7 +800,7 @@ cfs_hash_bd_order(struct cfs_hash_bd *bd1, struct cfs_hash_bd *bd2)
}
rc = cfs_hash_bd_compare(bd1, bd2);
- if (rc == 0)
+ if (!rc)
bd2->bd_bucket = NULL;
else if (rc > 0)
swap(*bd1, *bd2); /* swap bd1 and bd2 */
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 2/3] staging: lustre: libcfs: Remove unnecessary braces
2016-02-23 21:42 [PATCH v3 0/3] staging: lustre: libcfs: Use swap() and do some cleanups Amitoj Kaur Chawla
2016-02-23 21:42 ` [PATCH v3 1/3] staging: lustre: libcfs: Use swap() in cfs_hash_bd_order() Amitoj Kaur Chawla
2016-02-23 21:43 ` [PATCH v3 3/3] staging: lustre: libcfs: Remove comparison with zero Amitoj Kaur Chawla
@ 2016-02-23 21:43 ` Amitoj Kaur Chawla
2 siblings, 0 replies; 4+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-23 21:43 UTC (permalink / raw)
To: outreachy-kernel
Removed unncessary braces from the if-else block to remove the
following checkpatch.pl warning:
WARNING: braces {} are not necessary for any arm of this statement
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
Changes in v3:
-None
Changes in v2:
-Divided one patch into a series
drivers/staging/lustre/lustre/libcfs/hash.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c
index 8e6f9ac..fa0d23c 100644
--- a/drivers/staging/lustre/lustre/libcfs/hash.c
+++ b/drivers/staging/lustre/lustre/libcfs/hash.c
@@ -800,12 +800,10 @@ cfs_hash_bd_order(struct cfs_hash_bd *bd1, struct cfs_hash_bd *bd2)
}
rc = cfs_hash_bd_compare(bd1, bd2);
- if (rc == 0) {
+ if (rc == 0)
bd2->bd_bucket = NULL;
-
- } else if (rc > 0) {
+ else if (rc > 0)
swap(*bd1, *bd2); /* swap bd1 and bd2 */
- }
}
void
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-23 21:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-23 21:42 [PATCH v3 0/3] staging: lustre: libcfs: Use swap() and do some cleanups Amitoj Kaur Chawla
2016-02-23 21:42 ` [PATCH v3 1/3] staging: lustre: libcfs: Use swap() in cfs_hash_bd_order() Amitoj Kaur Chawla
2016-02-23 21:43 ` [PATCH v3 3/3] staging: lustre: libcfs: Remove comparison with zero Amitoj Kaur Chawla
2016-02-23 21:43 ` [PATCH v3 2/3] staging: lustre: libcfs: Remove unnecessary braces Amitoj Kaur Chawla
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.