From: Guy Harris Date: Sun, 20 Aug 2017 01:42:18 +0000 (-0700) Subject: Clean up some stuff. X-Git-Tag: tcpdump-4.99-bp~2031 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/d1a2d1853986740219664fd009b8eaa0e0416758 Clean up some stuff. Make the loop index an int, and just cast the (small) size of an IPv6 address, in units of two-byte chunks, to int. Use int rather than long for the base and length; they'll never be large enough to require a long. --- diff --git a/addrtostr.c b/addrtostr.c index 92875622..6f6ef11a 100644 --- a/addrtostr.c +++ b/addrtostr.c @@ -110,11 +110,11 @@ addrtostr6 (const void *src, char *dst, size_t size) size_t space_left, added_space; int snprintfed; struct { - long base; - long len; + int base; + int len; } best, cur; u_long words [IN6ADDRSZ / INT16SZ]; - u_int i; + int i; /* Preprocess: * Copy the input (bytewise) array into a wordwise array. @@ -128,7 +128,7 @@ addrtostr6 (const void *src, char *dst, size_t size) best.base = -1; cur.len = 0; cur.base = -1; - for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) + for (i = 0; i < (int)(IN6ADDRSZ / INT16SZ); i++) { if (words[i] == 0) { @@ -161,7 +161,7 @@ addrtostr6 (const void *src, char *dst, size_t size) *dp++ = c; \ space_left--; \ } - for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) + for (i = 0; i < (int)(IN6ADDRSZ / INT16SZ); i++) { /* Are we inside the best run of 0x00's? */