Fix compiler warning

This commit is contained in:
Yang Tse 2006-08-04 02:49:04 +00:00
parent f55924b3e0
commit 8f8ba9486d
2 changed files with 16 additions and 5 deletions

View File

@ -129,8 +129,12 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
* Keep this in mind if you think this function should have been coded * Keep this in mind if you think this function should have been coded
* to use pointer overlays. All the world's not a VAX. * to use pointer overlays. All the world's not a VAX.
*/ */
char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
struct { int base, len; } best = { 0,0 }, cur = { 0,0 }; char *tp;
struct {
long base;
long len;
} best, cur;
unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ]; unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
int i; int i;
@ -142,8 +146,12 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
memset(words, '\0', sizeof words); memset(words, '\0', sizeof words);
for (i = 0; i < NS_IN6ADDRSZ; i++) for (i = 0; i < NS_IN6ADDRSZ; i++)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1; best.base = -1;
cur.base = -1; cur.base = -1;
best.len = 0;
cur.len = 0;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
{ {
if (words[i] == 0) if (words[i] == 0)

View File

@ -106,14 +106,14 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
* Keep this in mind if you think this function should have been coded * Keep this in mind if you think this function should have been coded
* to use pointer overlays. All the world's not a VAX. * to use pointer overlays. All the world's not a VAX.
*/ */
char tmp [sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
char *tp; char *tp;
struct { struct {
long base; long base;
long len; long len;
} best, cur; } best, cur;
u_long words [IN6ADDRSZ / INT16SZ]; unsigned long words[IN6ADDRSZ / INT16SZ];
int i; int i;
/* Preprocess: /* Preprocess:
* Copy the input (bytewise) array into a wordwise array. * Copy the input (bytewise) array into a wordwise array.
@ -125,6 +125,9 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
best.base = -1; best.base = -1;
cur.base = -1; cur.base = -1;
best.len = 0;
cur.len = 0;
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
{ {
if (words[i] == 0) if (words[i] == 0)