linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: nsp32: fix logic bug in error handling
@ 2017-09-05  7:51 Arnd Bergmann
  2017-10-15 23:51 ` Masanori Goto
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2017-09-05  7:51 UTC (permalink / raw)
  To: GOTO Masanori, YOKOTA Hiroshi, James E.J. Bottomley, Martin K. Petersen
  Cc: Arnd Bergmann, Hannes Reinecke, Johannes Thumshirn, linux-scsi,
	linux-kernel

gcc-8 points out a logic error that has existed since the start
of the git history:

drivers/scsi/nsp32.c: In function 'nsp32_selection_autoscsi':
drivers/scsi/nsp32.c:607:27: error: bitwise comparison always evaluates to false [-Werror=tautological-compare]
  if(((phase & BUSMON_BSY) == 1) || (phase & BUSMON_SEL) == 1) {
                           ^~

Presumably the author intended to check if one of two bits was
set, so that's what I'm changing the code to. This will obviously
change the behavior of the code, hopefully to do the right thing,
but I have not tested this or checked if the new "(phase & BUSMON_BSY)
|| (phase & BUSMON_SEL)" condition should indeed be treated as a
fatal error.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/nsp32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
index 107e191bf023..8620ac5d6e41 100644
--- a/drivers/scsi/nsp32.c
+++ b/drivers/scsi/nsp32.c
@@ -604,7 +604,7 @@ static int nsp32_selection_autoscsi(struct scsi_cmnd *SCpnt)
 	 * check bus line
 	 */
 	phase = nsp32_read1(base, SCSI_BUS_MONITOR);
-	if(((phase & BUSMON_BSY) == 1) || (phase & BUSMON_SEL) == 1) {
+	if ((phase & BUSMON_BSY) || (phase & BUSMON_SEL)) {
 		nsp32_msg(KERN_WARNING, "bus busy");
 		SCpnt->result = DID_BUS_BUSY << 16;
 		status = 1;
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-17  2:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-05  7:51 [PATCH] scsi: nsp32: fix logic bug in error handling Arnd Bergmann
2017-10-15 23:51 ` Masanori Goto
2017-10-17  2:39   ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).