Skip to contentSkip to conversation

drivers/scsi: correct use of ! and &

PATCH In review [email protected] 1 participant 1 message Mar 4, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drivers/scsi: correct use of ! and &

From: Julia Lawall <[email protected]>

!ep->esb_stat is either 1 or 0, and the rightmost bit of ESB_ST_COMPLETE is always 0, making the result of !ep->esb_stat & ESB_ST_COMPLETE always 0. Thus parentheses around the argument to ! seem needed.

The semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@ expression E; constant C; @@
(
!E & !C
|
- !E & C
+ !(E & C)
)
// </smpl>

---

 drivers/scsi/libfc/fc_exch.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/libfc/fc_exch.c renamed from drivers/scsi/libfc/fc_exch.c~drivers-scsi-correct-use-of-and +1 -1
diff -puN drivers/scsi/libfc/fc_exch.c~drivers-scsi-correct-use-of-and drivers/scsi/libfc/fc_exch.c
@@ -283,7 +283,7 @@ static void fc_exch_release(struct fc_ex
 			ep->destructor(&ep->seq, ep->arg);
 		if (ep->lp->tt.exch_put)
 			ep->lp->tt.exch_put(ep->lp, mp, ep->xid);
-		WARN_ON(!ep->esb_stat & ESB_ST_COMPLETE);
+		WARN_ON(!(ep->esb_stat & ESB_ST_COMPLETE));
 		mempool_free(ep, mp->ep_pool);
 	}
 }

_