Kevin Reay <kevintreayopen...@gmail.com> writes:

> Change printf format to print unsigned values. Minor spacing change of
> casts to match file/style(9).
>
> Attempted to match printf formating of unsigned 32bits to rest of
> file.

I don't think this is the good direction.  "seq" and "length" are 32bits
integers.  Why cast them to long, and then print them as unsigned long?
Let's just print them as unsigned int.

"ack" and "win" are unsigned shorts.  They can be printed using %u since
they are automatically promoted to unsigned ints.

Thoughts?

Index: print-tcp.c
===================================================================
RCS file: /cvs/src/usr.sbin/tcpdump/print-tcp.c,v
retrieving revision 1.33
diff -u -p -p -u -r1.33 print-tcp.c
--- print-tcp.c 20 Aug 2015 22:39:29 -0000      1.33
+++ print-tcp.c 4 Nov 2015 18:01:51 -0000
@@ -221,7 +221,7 @@ tcp_print(register const u_char *bp, reg
 
        ch = '\0';
        if (length < sizeof(*tp)) {
-               (void)printf("truncated-tcp %d", length);
+               (void)printf("truncated-tcp %u", length);
                return;
        }
 
@@ -476,15 +476,14 @@ tcp_print(register const u_char *bp, reg
 
        length -= hlen;
        if (vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST))
-               (void)printf(" %lu:%lu(%d)", (long) seq, (long) (seq + length),
-                   length);
+               (void)printf(" %u:%u(%u)", seq, seq + length, length);
        if (flags & TH_ACK)
                (void)printf(" ack %u", ack);
 
-       (void)printf(" win %d", win);
+       (void)printf(" win %u", win);
 
        if (flags & TH_URG)
-               (void)printf(" urg %d", urp);
+               (void)printf(" urg %u", urp);
        /*
         * Handle any options.
         */


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to