]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Clean up some stuff.
authorGuy Harris <[email protected]>
Sun, 20 Aug 2017 01:42:18 +0000 (18:42 -0700)
committerGuy Harris <[email protected]>
Sun, 20 Aug 2017 01:42:18 +0000 (18:42 -0700)
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.

addrtostr.c

index 92875622e361702425e78a4257800935880c446f..6f6ef11a5d168f449e44615fdc67c8ab0607270a 100644 (file)
@@ -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?
      */