]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Babel: rewrite w/o print buffer rotation
authorDenis Ovsienko <[email protected]>
Mon, 2 Jun 2014 11:02:32 +0000 (15:02 +0400)
committerDenis Ovsienko <[email protected]>
Mon, 2 Jun 2014 11:19:09 +0000 (15:19 +0400)
print-babel.c

index c7208048cec5931f46c7b63ebcdae07200dabf10..bd8b098e8b9c0db9fdc22684b54cd42a5659c444 100644 (file)
@@ -165,11 +165,9 @@ static const char *
 format_timestamp(const uint32_t i)
 {
     /* Rotating buffer. */
 format_timestamp(const uint32_t i)
 {
     /* Rotating buffer. */
-    static char buf[2][sizeof("0000.000000s")];
-    static int x = 0;
-    x = (x + 1) % 2;
-    snprintf(buf[x], sizeof(buf[x]), "%u.%06us", i / 1000000, i % 1000000);
-    return buf[x];
+    static char buf[sizeof("0000.000000s")];
+    snprintf(buf, sizeof(buf), "%u.%06us", i / 1000000, i % 1000000);
+    return buf;
 }
 
 /* Return number of octets consumed from the input buffer (not the prefix length
 }
 
 /* Return number of octets consumed from the input buffer (not the prefix length
@@ -320,9 +318,9 @@ subtlvs_print(netdissect_options *ndo,
                 if(sublen != 8)
                     goto corrupt;
                 t1 = EXTRACT_32BITS(cp);
                 if(sublen != 8)
                     goto corrupt;
                 t1 = EXTRACT_32BITS(cp);
+                ND_PRINT((ndo, " %s", format_timestamp(t1)));
                 t2 = EXTRACT_32BITS(cp + 4);
                 t2 = EXTRACT_32BITS(cp + 4);
-                ND_PRINT((ndo, " %s|%s",
-                          format_timestamp(t1), format_timestamp(t2)));
+                ND_PRINT((ndo, "|%s", format_timestamp(t2)));
             } else
                 ND_PRINT((ndo, " (bogus)"));
             cp += sublen;
             } else
                 ND_PRINT((ndo, " (bogus)"));
             cp += sublen;