Re: [PATCH 17/19] scsi_transport_srp: Suppress a W=1 compiler warning

Bart Van Assche
2017-08-25T15:41:37Z

On Fri, 2017-08-25 at 17:29 +0200, hch@lst.de wrote:
> On Thu, Aug 24, 2017 at 04:27:07PM +0000, Bart Van Assche wrote:
> >
> > The purpose of that check is to avoid that dev_loss_tmo * HZ can overflow.
> > That check is only needed on 32-bit systems since only on these systems
> > sizeof(long) == sizeof(int). How about changing the type of the dev_loss_tmo
> > argument from int to long such that no explicit cast is needed?
>
> Yes, switching the timeout to long sounds useful as that's our normal
> type for timeouts. But it will spread through a lot of the SRP code.

Hello Christoph,

Do you agree with the patch below? It seems to be sufficient to suppress
the compiler warning.

Thanks,

Bart.

[PATCH] scsi_transport_srp: Suppress a W=1 compiler warning

Avoid that the following compiler warning is reported when building
with W=1:

drivers/scsi/scsi_transport_srp.c:92:19: warning: comparison is always false due to limited range of data type [-Wtype-limits]

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
drivers/scsi/scsi_transport_srp.c | 2 +-
include/scsi/scsi_transport_srp.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index 698cc4681706..4f6f01cf9968 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -78,7 +78,7 @@ static inline struct srp_rport *shost_to_rport(struct Scsi_Host *shost)
* parameters must be such that multipath can detect failed paths timely.
* Hence do not allow all three parameters to be disabled simultaneously.
*/
-int srp_tmo_valid(int reconnect_delay, int fast_io_fail_tmo, int dev_loss_tmo)
+int srp_tmo_valid(int reconnect_delay, int fast_io_fail_tmo, long dev_loss_tmo)
{
if (reconnect_delay < 0 && fast_io_fail_tmo < 0 && dev_loss_tmo < 0)
return -EINVAL;
diff --git a/include/scsi/scsi_transport_srp.h b/include/scsi/scsi_transport_srp.h
index dd096330734e..56ae198acc73 100644
--- a/include/scsi/scsi_transport_srp.h
+++ b/include/scsi/scsi_transport_srp.h
@@ -111,7 +111,7 @@ extern struct srp_rport *srp_rport_add(struct Scsi_Host *,
struct srp_rport_identifiers *);
extern void srp_rport_del(struct srp_rport *);
extern int srp_tmo_valid(int reconnect_delay, int fast_io_fail_tmo,
- int dev_loss_tmo);
+ long dev_loss_tmo);
int srp_parse_tmo(int *tmo, const char *buf);
extern int srp_reconnect_rport(struct srp_rport *rport);
extern void srp_start_tl_fail_timers(struct srp_rport *rport);