1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

Fixed some compiler warnings I should have noticed before.

This commit is contained in:
Dan Fandrich 2005-03-16 02:25:12 +00:00
parent efaf688650
commit bf87d13f5b
3 changed files with 7 additions and 10 deletions

View File

@ -69,6 +69,7 @@
#include <inet.h> #include <inet.h>
#endif #endif
#include "inet_ntop.h"
#include "memory.h" #include "memory.h"
/* The last #include file should be: */ /* The last #include file should be: */

View File

@ -54,17 +54,13 @@
* - uses no statics * - uses no statics
* - takes a u_char* not an in_addr as input * - takes a u_char* not an in_addr as input
*/ */
static const char *inet_ntop4 (const u_char *src, char *dst, size_t size) static char *inet_ntop4 (const u_char *src, char *dst, size_t size)
{ {
#if defined(HAVE_INET_NTOA_R_2_ARGS) #if defined(HAVE_INET_NTOA_R_2_ARGS)
const char *ptr; const char *ptr;
size_t len;
curlassert(size >= 16); curlassert(size >= 16);
ptr = inet_ntoa_r(*(struct in_addr*)src, dst); ptr = inet_ntoa_r(*(struct in_addr*)src, dst);
len = strlen(ptr); return (char *)memmove(dst, ptr, strlen(ptr)+1);
memmove(dst, ptr, len);
dst[len] = 0;
return dst;
#elif defined(HAVE_INET_NTOA_R) #elif defined(HAVE_INET_NTOA_R)
return inet_ntoa_r(*(struct in_addr*)src, dst, size); return inet_ntoa_r(*(struct in_addr*)src, dst, size);
@ -85,7 +81,7 @@ static const char *inet_ntop4 (const u_char *src, char *dst, size_t size)
/* /*
* Convert IPv6 binary address into presentation (printable) format. * Convert IPv6 binary address into presentation (printable) format.
*/ */
static const char *inet_ntop6 (const u_char *src, char *dst, size_t size) static char *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 * Note that int32_t and int16_t need only be "at least" large enough
@ -189,10 +185,10 @@ static const char *inet_ntop6 (const u_char *src, char *dst, size_t size)
/* /*
* Convert a network format address to presentation format. * Convert a network format address to presentation format.
* *
* Returns pointer to presentation format address (`dst'), * Returns pointer to presentation format address (`buf'),
* Returns NULL on error (see errno). * Returns NULL on error (see errno).
*/ */
const char *Curl_inet_ntop(int af, const void *src, char *buf, size_t size) char *Curl_inet_ntop(int af, const void *src, char *buf, size_t size)
{ {
switch (af) { switch (af) {
case AF_INET: case AF_INET:

View File

@ -31,7 +31,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#else #else
const char *Curl_inet_ntop(int af, const void *addr, char *buf, size_t size); char *Curl_inet_ntop(int af, const void *addr, char *buf, size_t size);
#endif #endif
#endif /* __INET_NTOP_H */ #endif /* __INET_NTOP_H */