diff options
author | Gao Feng <fgao@ikuai8.com> | 2017-02-21 17:09:19 +0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-02-21 12:25:21 -0500 |
commit | 8ccde4c562076f280c0321c549d822448b64e565 (patch) | |
tree | ade08c5030db335c54d3ad32c02b39b8efeaee05 /net | |
parent | f6b10209b90d48a84f886ab2b317b5d2cbfe3143 (diff) | |
download | linux-8ccde4c562076f280c0321c549d822448b64e565.tar.gz linux-8ccde4c562076f280c0321c549d822448b64e565.tar.bz2 linux-8ccde4c562076f280c0321c549d822448b64e565.zip |
net: sock: Use USEC_PER_SEC macro instead of literal 1000000
The USEC_PER_SEC is used once in sock_set_timeout as the max value of
tv_usec. But there are other similar codes which use the literal
1000000 in this file.
It is minor cleanup to keep consitent.
Signed-off-by: Gao Feng <fgao@ikuai8.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/sock.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index b74356535559..e7d74940e863 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -367,7 +367,7 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen) if (tv.tv_sec == 0 && tv.tv_usec == 0) return 0; if (tv.tv_sec < (MAX_SCHEDULE_TIMEOUT/HZ - 1)) - *timeo_p = tv.tv_sec*HZ + (tv.tv_usec+(1000000/HZ-1))/(1000000/HZ); + *timeo_p = tv.tv_sec * HZ + DIV_ROUND_UP(tv.tv_usec, USEC_PER_SEC / HZ); return 0; } @@ -1146,7 +1146,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname, v.tm.tv_usec = 0; } else { v.tm.tv_sec = sk->sk_rcvtimeo / HZ; - v.tm.tv_usec = ((sk->sk_rcvtimeo % HZ) * 1000000) / HZ; + v.tm.tv_usec = ((sk->sk_rcvtimeo % HZ) * USEC_PER_SEC) / HZ; } break; @@ -1157,7 +1157,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname, v.tm.tv_usec = 0; } else { v.tm.tv_sec = sk->sk_sndtimeo / HZ; - v.tm.tv_usec = ((sk->sk_sndtimeo % HZ) * 1000000) / HZ; + v.tm.tv_usec = ((sk->sk_sndtimeo % HZ) * USEC_PER_SEC) / HZ; } break; |