diff options
Diffstat (limited to 'compat/inet_ntop.c')
-rw-r--r-- | compat/inet_ntop.c | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/compat/inet_ntop.c b/compat/inet_ntop.c index f44498258d..90b7cc45f3 100644 --- a/compat/inet_ntop.c +++ b/compat/inet_ntop.c @@ -15,13 +15,7 @@ * SOFTWARE. */ -#include <errno.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <stdio.h> -#include <string.h> +#include "../git-compat-util.h" #ifndef NS_INADDRSZ #define NS_INADDRSZ 4 @@ -50,10 +44,7 @@ * Paul Vixie, 1996. */ static const char * -inet_ntop4(src, dst, size) - const u_char *src; - char *dst; - size_t size; +inet_ntop4(const u_char *src, char *dst, size_t size) { static const char fmt[] = "%u.%u.%u.%u"; char tmp[sizeof "255.255.255.255"]; @@ -78,10 +69,7 @@ inet_ntop4(src, dst, size) * Paul Vixie, 1996. */ static const char * -inet_ntop6(src, dst, size) - const u_char *src; - char *dst; - size_t size; +inet_ntop6(const u_char *src, char *dst, size_t size) { /* * Note that int32_t and int16_t need only be "at least" large enough @@ -104,7 +92,9 @@ inet_ntop6(src, dst, size) for (i = 0; i < NS_IN6ADDRSZ; i++) words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); best.base = -1; + best.len = 0; cur.base = -1; + cur.len = 0; for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { if (words[i] == 0) { if (cur.base == -1) @@ -178,11 +168,7 @@ inet_ntop6(src, dst, size) * Paul Vixie, 1996. */ const char * -inet_ntop(af, src, dst, size) - int af; - const void *src; - char *dst; - size_t size; +inet_ntop(int af, const void *src, char *dst, size_t size) { switch (af) { case AF_INET: |