Skip to contentSkip to conversation

staging: rdma: hfi1: Do not use | with a variable with value 0

PATCH New Janani Ravichandran 1 participant 1 message Feb 23, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rdma: hfi1: Do not use | with a variable with value 0

mr->lkey has a value equal to 0. There is no need to combine it with other things with | as for any value x, 0|x is always x. Semantic patch used:
@@
expression x, e, e1;
statement S;
@@

  if (x == 0) {
    ... when != x = e1
        when != while(...) S
	when != for(...;...;...) S

(
* x |= e
|
* x | e
)
... when any
}

---
 drivers/staging/rdma/hfi1/keys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rdma/hfi1/keys.c +1 -1
index cb4e608..e34f093 100644
@@ -113,7 +113,7 @@ int hfi1_alloc_lkey(struct hfi1_mregion *mr, int dma_region)
 		((((1 << (24 - hfi1_lkey_table_size)) - 1) & rkt->gen)
 		 << 8);
 	if (mr->lkey == 0) {
-		mr->lkey |= 1 << 8;
+		mr->lkey = 1 << 8;
 		rkt->gen++;
 	}
 	rcu_assign_pointer(rkt->table[r], mr);
Signature · 1 line
2.5.0