]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
inet_ntop replacement: do not depend on socklen_t
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 19 Mar 2015 10:03:24 +0000 (11:03 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 19 Mar 2015 10:03:51 +0000 (11:03 +0100)
lib/inet_ntop.c
lib/system.h

index e7d52f0c59c744779504bdb35cf72163025b202a..2224dbad25fe3bc1e75982bdb7e32dc5b6f59f03 100644 (file)
@@ -57,9 +57,9 @@
  */
 typedef int verify_int_size[4 <= sizeof (int) ? 1 : -1];
 
-static const char *inet_ntop4 (const unsigned char *src, char *dst, socklen_t size);
+static const char *inet_ntop4 (const unsigned char *src, char *dst, unsigned size);
 # if HAVE_IPV6
-static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t size);
+static const char *inet_ntop6 (const unsigned char *src, char *dst, unsigned size);
 # endif
 
 
@@ -73,7 +73,7 @@ static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t si
  */
 const char *
 inet_ntop (int af, const void *restrict src,
-           char *restrict dst, socklen_t cnt)
+           char *restrict dst, unsigned cnt)
 {
   switch (af)
     {
@@ -106,7 +106,7 @@ inet_ntop (int af, const void *restrict src,
  *      Paul Vixie, 1996.
  */
 static const char *
-inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
+inet_ntop4 (const unsigned char *src, char *dst, unsigned size)
 {
   char tmp[sizeof "255.255.255.255"];
   int len;
@@ -133,7 +133,7 @@ inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
  *      Paul Vixie, 1996.
  */
 static const char *
-inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
+inet_ntop6 (const unsigned char *src, char *dst, unsigned size)
 {
   /*
    * Note that int32_t and int16_t need only be "at least" large enough
@@ -230,7 +230,7 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
   /*
    * Check for overflow, copy, and we're done.
    */
-  if ((socklen_t) (tp - tmp) > size)
+  if ((unsigned) (tp - tmp) > size)
     {
       errno = ENOSPC;
       return NULL;
index 9f4fc33c011ea3e2e167e8559d1c5e0cd5e12852..03cf7fd4942a83f0b787bb5b1bf60caf46b01146 100644 (file)
@@ -115,7 +115,7 @@ int inet_pton(int af, const char *src, void *dst);
 #ifndef HAVE_INET_NTOP
 # define inet_ntop _gnutls_inet_ntop
 const char *inet_ntop(int af, const void *src,
-                     char *dst, socklen_t size);
+                     char *dst, unsigned size);
 #endif
 
 #endif                         /* SYSTEM_H */