ares_inet_ntop: remove definition and usage of macro SPRINTF
authorYang Tse <yangsita@gmail.com>
Thu, 16 Dec 2010 20:27:56 +0000 (21:27 +0100)
committerYang Tse <yangsita@gmail.com>
Thu, 16 Dec 2010 20:27:56 +0000 (21:27 +0100)
Existing definition of SPRINTF always resulted in sprintf() being used,
and sprintf() returning 'int' is already used throughout the library.

inet_ntop.c

index 6de0a6d..07d3f5a 100644 (file)
 
 #ifndef HAVE_INET_NTOP
 
-#ifdef SPRINTF_CHAR
-# define SPRINTF(x) strlen(sprintf/**/x)
-#else
-# define SPRINTF(x) ((size_t)sprintf x)
-#endif
-
 /*
  * WARNING: Don't even consider trying to compile this on a system where
  * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
@@ -107,7 +101,7 @@ inet_ntop4(const unsigned char *src, char *dst, size_t size)
   static const char fmt[] = "%u.%u.%u.%u";
   char tmp[sizeof("255.255.255.255")];
 
-  if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) >= size) {
+  if ((size_t)sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) >= size) {
     SET_ERRNO(ENOSPC);
     return (NULL);
   }
@@ -194,7 +188,7 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
       tp += strlen(tp);
       break;
     }
-    tp += SPRINTF((tp, "%x", words[i]));
+    tp += sprintf(tp, "%x", words[i]);
   }
   /* Was it a trailing run of 0x00's? */
   if (best.base != -1 && (best.base + best.len) ==