提交 356f89e1 编写于 作者: I Ilpo Järvinen 提交者: David S. Miller

[NET] Cleanup: DIV_ROUND_UP

Signed-off-by: NIlpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 18f02545
...@@ -646,11 +646,7 @@ static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned ...@@ -646,11 +646,7 @@ static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned
skb_shinfo(skb)->gso_size = 0; skb_shinfo(skb)->gso_size = 0;
skb_shinfo(skb)->gso_type = 0; skb_shinfo(skb)->gso_type = 0;
} else { } else {
unsigned int factor; skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(skb->len, mss_now);
factor = skb->len + (mss_now - 1);
factor /= mss_now;
skb_shinfo(skb)->gso_segs = factor;
skb_shinfo(skb)->gso_size = mss_now; skb_shinfo(skb)->gso_size = mss_now;
skb_shinfo(skb)->gso_type = sk->sk_gso_type; skb_shinfo(skb)->gso_type = sk->sk_gso_type;
} }
......
...@@ -352,16 +352,14 @@ static int verify_address_len(void *p) ...@@ -352,16 +352,14 @@ static int verify_address_len(void *p)
switch (addr->sa_family) { switch (addr->sa_family) {
case AF_INET: case AF_INET:
len = sizeof(*sp) + sizeof(*sin) + (sizeof(uint64_t) - 1); len = DIV_ROUND_UP(sizeof(*sp) + sizeof(*sin), sizeof(uint64_t));
len /= sizeof(uint64_t);
if (sp->sadb_address_len != len || if (sp->sadb_address_len != len ||
sp->sadb_address_prefixlen > 32) sp->sadb_address_prefixlen > 32)
return -EINVAL; return -EINVAL;
break; break;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6: case AF_INET6:
len = sizeof(*sp) + sizeof(*sin6) + (sizeof(uint64_t) - 1); len = DIV_ROUND_UP(sizeof(*sp) + sizeof(*sin6), sizeof(uint64_t));
len /= sizeof(uint64_t);
if (sp->sadb_address_len != len || if (sp->sadb_address_len != len ||
sp->sadb_address_prefixlen > 128) sp->sadb_address_prefixlen > 128)
return -EINVAL; return -EINVAL;
...@@ -386,14 +384,9 @@ static int verify_address_len(void *p) ...@@ -386,14 +384,9 @@ static int verify_address_len(void *p)
static inline int pfkey_sec_ctx_len(struct sadb_x_sec_ctx *sec_ctx) static inline int pfkey_sec_ctx_len(struct sadb_x_sec_ctx *sec_ctx)
{ {
int len = 0; return DIV_ROUND_UP(sizeof(struct sadb_x_sec_ctx) +
sec_ctx->sadb_x_ctx_len,
len += sizeof(struct sadb_x_sec_ctx); sizeof(uint64_t));
len += sec_ctx->sadb_x_ctx_len;
len += sizeof(uint64_t) - 1;
len /= sizeof(uint64_t);
return len;
} }
static inline int verify_sec_ctx_len(void *p) static inline int verify_sec_ctx_len(void *p)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册