aboutsummaryrefslogtreecommitdiffstats
path: root/net/key/af_key.c
diff options
context:
space:
mode:
authorIlpo Järvinen <ilpo.jarvinen@helsinki.fi>2007-08-25 02:00:31 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:48:30 -0400
commit356f89e12e301376f26795643f3b5931c81c9cd5 (patch)
treee9e180c3d39ea97e28e5b81e1ca26b32b1ff6e66 /net/key/af_key.c
parent18f02545a9a16c9a89778b91a162ad16d510bb32 (diff)
[NET] Cleanup: DIV_ROUND_UP
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/key/af_key.c')
-rw-r--r--net/key/af_key.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 5502df115a63..17b2a6927f01 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -352,16 +352,14 @@ static int verify_address_len(void *p)
352 352
353 switch (addr->sa_family) { 353 switch (addr->sa_family) {
354 case AF_INET: 354 case AF_INET:
355 len = sizeof(*sp) + sizeof(*sin) + (sizeof(uint64_t) - 1); 355 len = DIV_ROUND_UP(sizeof(*sp) + sizeof(*sin), sizeof(uint64_t));
356 len /= sizeof(uint64_t);
357 if (sp->sadb_address_len != len || 356 if (sp->sadb_address_len != len ||
358 sp->sadb_address_prefixlen > 32) 357 sp->sadb_address_prefixlen > 32)
359 return -EINVAL; 358 return -EINVAL;
360 break; 359 break;
361#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 360#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
362 case AF_INET6: 361 case AF_INET6:
363 len = sizeof(*sp) + sizeof(*sin6) + (sizeof(uint64_t) - 1); 362 len = DIV_ROUND_UP(sizeof(*sp) + sizeof(*sin6), sizeof(uint64_t));
364 len /= sizeof(uint64_t);
365 if (sp->sadb_address_len != len || 363 if (sp->sadb_address_len != len ||
366 sp->sadb_address_prefixlen > 128) 364 sp->sadb_address_prefixlen > 128)
367 return -EINVAL; 365 return -EINVAL;
@@ -386,14 +384,9 @@ static int verify_address_len(void *p)
386 384
387static inline int pfkey_sec_ctx_len(struct sadb_x_sec_ctx *sec_ctx) 385static inline int pfkey_sec_ctx_len(struct sadb_x_sec_ctx *sec_ctx)
388{ 386{
389 int len = 0; 387 return DIV_ROUND_UP(sizeof(struct sadb_x_sec_ctx) +
390 388 sec_ctx->sadb_x_ctx_len,
391 len += sizeof(struct sadb_x_sec_ctx); 389 sizeof(uint64_t));
392 len += sec_ctx->sadb_x_ctx_len;
393 len += sizeof(uint64_t) - 1;
394 len /= sizeof(uint64_t);
395
396 return len;
397} 390}
398 391
399static inline int verify_sec_ctx_len(void *p) 392static inline int verify_sec_ctx_len(void *p)