Skip to content

Commit

Permalink
ares_inet_ntop: remove definition and usage of macro SPRINTF
Browse files Browse the repository at this point in the history
Existing definition of SPRINTF always resulted in sprintf() being used,
and sprintf() returning 'int' is already used throughout the library.
  • Loading branch information
yangtse committed Dec 16, 2010
1 parent 52f493c commit 3670427
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions inet_ntop.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@

#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.
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) ==
Expand Down

0 comments on commit 3670427

Please sign in to comment.