From: Augusto Mecking Caringi <augustocaringi@gmail.com>
To: "James E . J . Bottomley" <jejb@linux.vnet.ibm.com>
Cc: Augusto Mecking Caringi <augustocaringi@gmail.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
"Ewan D. Milne" <emilne@redhat.com>,
Bart Van Assche <bart.vanassche@sandisk.com>,
Sagi Grimberg <sagi@grimberg.me>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] scsi: srp_transport: Fix 'always false comparison' in srp_tmo_valid()
Date: Thu, 26 Jan 2017 11:17:16 +0000 [thread overview]
Message-ID: <1485429447-19103-1-git-send-email-augustocaringi@gmail.com> (raw)
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@gmail.com>
---
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
next reply other threads:[~2017-01-26 11:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-26 11:17 Augusto Mecking Caringi [this message]
2017-01-26 15:11 ` [PATCH] scsi: srp_transport: Fix 'always false comparison' in srp_tmo_valid() Bart Van Assche
2017-01-27 10:06 ` Augusto Mecking Caringi
2017-01-27 19:42 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1485429447-19103-1-git-send-email-augustocaringi@gmail.com \
--to=augustocaringi@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bart.vanassche@sandisk.com \
--cc=emilne@redhat.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox