diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2013-04-04 17:49:34 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2013-04-04 17:49:34 +0000 |
commit | 06bd0f562737db191ae797699d1f6478171682aa (patch) | |
tree | d5187d3b6cf1e231988522c547f2a076d14f3eb2 /lib | |
parent | fe585b647bf5a928c2f133bae11b94d19bef9ce2 (diff) |
use the provided ALIGN() macro instead of re-inventing a square wheel.
prodded by deraadt@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/asr/gethostnamadr.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/libc/asr/gethostnamadr.c b/lib/libc/asr/gethostnamadr.c index 1ed1dcf460c..635306cbe54 100644 --- a/lib/libc/asr/gethostnamadr.c +++ b/lib/libc/asr/gethostnamadr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gethostnamadr.c,v 1.4 2013/04/01 15:49:54 deraadt Exp $ */ +/* $OpenBSD: gethostnamadr.c,v 1.5 2013/04/04 17:49:33 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -26,10 +26,6 @@ #include "asr.h" -#define PALIGN(p, l) \ - ((char *)(p) + (((uintptr_t)(p) % (l)) ? \ - (l) - (uintptr_t)(p) % (l) : 0)) - static struct hostent *_gethostbyname(const char *, int); static void _fillhostent(const struct hostent *, struct hostent *, char *buf, size_t); @@ -52,7 +48,7 @@ _fillhostent(const struct hostent *h, struct hostent *r, char *buf, size_t len) r->h_addr_list = _empty; end = buf + len; - ptr = (char **)PALIGN(buf, sizeof(char *)); + ptr = (char **)ALIGN(buf); if ((char *)ptr >= end) return; @@ -86,7 +82,7 @@ _fillhostent(const struct hostent *h, struct hostent *r, char *buf, size_t len) pos += n + 1; } - pos = PALIGN(pos, r->h_length); + pos = (char*)ALIGN(pos); if (pos >= end) return; |