Patchwork [1/1] net/sctp/socket.c: squish warning

login
register
mail settings
Submitter Andrew Morton
Date Dec. 22, 2009, 12:25 a.m.
Message ID <200912220025.nBM0P6iQ005122@imap1.linux-foundation.org>
Download mbox | patch
Permalink /patch/41568/
State Accepted
Delegated to: David Miller
Headers show

Comments

Andrew Morton - Dec. 22, 2009, 12:25 a.m.
From: Andrew Morton <akpm@linux-foundation.org>

net/sctp/socket.c: In function 'sctp_setsockopt_autoclose':
net/sctp/socket.c:2090: warning: comparison is always false due to limited range of data type

Cc: Andrei Pelinescu-Onciul <andrei@iptel.org>
Cc: Vlad Yasevich <vladislav.yasevich@hp.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 net/sctp/socket.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
David Miller - Jan. 4, 2010, 5:26 a.m.
From: akpm@linux-foundation.org
Date: Mon, 21 Dec 2009 16:25:06 -0800

> From: Andrew Morton <akpm@linux-foundation.org>
> 
> net/sctp/socket.c: In function 'sctp_setsockopt_autoclose':
> net/sctp/socket.c:2090: warning: comparison is always false due to limited range of data type
> 
> Cc: Andrei Pelinescu-Onciul <andrei@iptel.org>
> Cc: Vlad Yasevich <vladislav.yasevich@hp.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

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

Patch

diff -puN net/sctp/socket.c~net-sctp-socketc-squish-warning net/sctp/socket.c
--- a/net/sctp/socket.c~net-sctp-socketc-squish-warning
+++ a/net/sctp/socket.c
@@ -2087,8 +2087,7 @@  static int sctp_setsockopt_autoclose(str
 	if (copy_from_user(&sp->autoclose, optval, optlen))
 		return -EFAULT;
 	/* make sure it won't exceed MAX_SCHEDULE_TIMEOUT */
-	if (sp->autoclose > (MAX_SCHEDULE_TIMEOUT / HZ) )
-		sp->autoclose = (__u32)(MAX_SCHEDULE_TIMEOUT / HZ) ;
+	sp->autoclose = min_t(long, sp->autoclose, MAX_SCHEDULE_TIMEOUT / HZ);
 
 	return 0;
 }