[PATCH] scsi: srp_transport: Fix 'always false comparison' in srp_tmo_valid()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In a 64bit system (where long is 64bit wide), even dividing LONG_MAX by
HZ will always be bigger than the max value that an int variable can
hold.

This has been detected by building the driver with W=1:

drivers/scsi/scsi_transport_srp.c: In function ‘srp_tmo_valid’:
drivers/scsi/scsi_transport_srp.c:92:19: warning: comparison is always
false due to limited range of data type [-Wtype-limits]
if (dev_loss_tmo >= LONG_MAX / HZ)
                   ^

Signed-off-by: Augusto Mecking Caringi <augustocaringi@xxxxxxxxx>
---
 drivers/scsi/scsi_transport_srp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index b87a786..d8c83f4 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -89,7 +89,7 @@ int srp_tmo_valid(int reconnect_delay, int fast_io_fail_tmo, int dev_loss_tmo)
 	if (fast_io_fail_tmo < 0 &&
 	    dev_loss_tmo > SCSI_DEVICE_BLOCK_MAX_TIMEOUT)
 		return -EINVAL;
-	if (dev_loss_tmo >= LONG_MAX / HZ)
+	if (dev_loss_tmo >= INT_MAX / HZ)
 		return -EINVAL;
 	if (fast_io_fail_tmo >= 0 && dev_loss_tmo >= 0 &&
 	    fast_io_fail_tmo >= dev_loss_tmo)
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux