Skip to contentSkip to conversation

staging: lustre: Replace a bit shift by a use of BIT.

PATCH Superseded Arushi Singhal 2 participants 2 messages Mar 22, 2017 – Mar 23, 2017 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: lustre: Replace a bit shift by a use of BIT.

This patch replaces bit shifting on 1 with the BIT(x) macro. This was done with coccinelle:
@@
constant c;
@@

-1 << c
+BIT(c)

---
changes in v2
- remove the unnecessary parenthesis.
- removethe wrong changes.

 drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 8 ++++----
 drivers/staging/lustre/lnet/lnet/lib-ptl.c             | 2 +-
 drivers/staging/lustre/lustre/llite/lproc_llite.c      | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +4 -4
index eaa4399e6a2e..2b93ceaa2844 100644
@@ -1906,14 +1906,14 @@ ksocknal_connect(struct ksock_route *route)
 		if (retry_later) /* needs reschedule */
 			break;
 
-		if (wanted & (1 << SOCKLND_CONN_ANY)) {
+		if (wanted & BIT(SOCKLND_CONN_ANY)) {
 			type = SOCKLND_CONN_ANY;
-		} else if (wanted & (1 << SOCKLND_CONN_CONTROL)) {
+		} else if (wanted & BIT(SOCKLND_CONN_CONTROL)) {
 			type = SOCKLND_CONN_CONTROL;
-		} else if (wanted & (1 << SOCKLND_CONN_BULK_IN)) {
+		} else if (wanted & BIT(SOCKLND_CONN_BULK_IN)) {
 			type = SOCKLND_CONN_BULK_IN;
 		} else {
-			LASSERT(wanted & (1 << SOCKLND_CONN_BULK_OUT));
+			LASSERT(wanted & BIT(SOCKLND_CONN_BULK_OUT));
 			type = SOCKLND_CONN_BULK_OUT;
 		}
 
drivers/staging/lustre/lnet/lnet/lib-ptl.c +1 -1
index 63cce0c4a065..33332724ab94 100644
@@ -334,7 +334,7 @@ lnet_mt_test_exhausted(struct lnet_match_table *mtable, int pos)
 	bmap = &mtable->mt_exhausted[pos >> LNET_MT_BITS_U64];
 	pos &= (1 << LNET_MT_BITS_U64) - 1;
 
-	return (*bmap & (1ULL << pos));
+	return (*bmap & BIT(pos));
 }
 
 static void
drivers/staging/lustre/lustre/llite/lproc_llite.c +1 -1
index 40f1fcf8b5c0..c742cba60199 100644
@@ -1308,7 +1308,7 @@ static void ll_display_extents_info(struct ll_rw_extents_info *io_extents,
 			   r, pct(r, read_tot), pct(read_cum, read_tot),
 			   w, pct(w, write_tot), pct(write_cum, write_tot));
 		start = end;
-		if (start == 1 << 10) {
+		if (start == 1024) {
 			start = 1;
 			units += 10;
 			unitp++;
Signature · 1 line
2.11.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Arushi Singhal

This patch replaces bit shifting on 1 with the BIT(x) macro. This was done with coccinelle:
@@
constant c;
@@

-1 << c
+BIT(c)

Quoted 62 lines

---
changes in v2
- remove the unnecessary parenthesis.
- removethe wrong changes.

drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 8 ++++----
drivers/staging/lustre/lnet/lnet/lib-ptl.c             | 2 +-
drivers/staging/lustre/lustre/llite/lproc_llite.c      | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +4 -4
index eaa4399e6a2e..2b93ceaa2844 100644
@@ -1906,14 +1906,14 @@ ksocknal_connect(struct ksock_route *route)
 		if (retry_later) /* needs reschedule */
 			break;
 
-		if (wanted & (1 << SOCKLND_CONN_ANY)) {
+		if (wanted & BIT(SOCKLND_CONN_ANY)) {
 			type = SOCKLND_CONN_ANY;
-		} else if (wanted & (1 << SOCKLND_CONN_CONTROL)) {
+		} else if (wanted & BIT(SOCKLND_CONN_CONTROL)) {
 			type = SOCKLND_CONN_CONTROL;
-		} else if (wanted & (1 << SOCKLND_CONN_BULK_IN)) {
+		} else if (wanted & BIT(SOCKLND_CONN_BULK_IN)) {
 			type = SOCKLND_CONN_BULK_IN;
 		} else {
-			LASSERT(wanted & (1 << SOCKLND_CONN_BULK_OUT));
+			LASSERT(wanted & BIT(SOCKLND_CONN_BULK_OUT));
 			type = SOCKLND_CONN_BULK_OUT;
 		}
 
drivers/staging/lustre/lnet/lnet/lib-ptl.c +1 -1
index 63cce0c4a065..33332724ab94 100644
@@ -334,7 +334,7 @@ lnet_mt_test_exhausted(struct lnet_match_table *mtable, int pos)
 	bmap = &mtable->mt_exhausted[pos >> LNET_MT_BITS_U64];
 	pos &= (1 << LNET_MT_BITS_U64) - 1;
 
-	return (*bmap & (1ULL << pos));
+	return (*bmap & BIT(pos));
 }
 

static void

drivers/staging/lustre/lustre/llite/lproc_llite.c +1 -1
index 40f1fcf8b5c0..c742cba60199 100644
@@ -1308,7 +1308,7 @@ static void ll_display_extents_info(struct ll_rw_extents_info *io_extents,
 			   r, pct(r, read_tot), pct(read_cum, read_tot),
 			   w, pct(w, write_tot), pct(write_cum, write_tot));
 		start = end;
-		if (start == 1 << 10) {
+		if (start == 1024) {
 			start = 1;
 			units += 10;
 			unitp++;
Signature · 1 line
2.11.0

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation