Change printf format strings to print unsigned values throughout
print_ip.c. Precursor to future changes.
Index: print-ip.c
===================================================================
RCS file: /cvs/src/usr.sbin/tcpdump/print-ip.c,v
retrieving revision 1.44
diff -u -p -r1.44 print-ip.c
--- print-ip.c  21 Aug 2015 02:07:32 -0000      1.44
+++ print-ip.c  8 Nov 2015 21:07:59 -0000
@@ -127,22 +127,22 @@ static void print_mtrace(register const 
 {
        register struct tr_query *tr = (struct tr_query *)(bp + 8);
 
-       printf("mtrace %d: %s to %s reply-to %s", tr->tr_qid,
+       printf("mtrace %u: %s to %s reply-to %s", tr->tr_qid,
                ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
                ipaddr_string(&tr->tr_raddr));
        if (IN_CLASSD(ntohl(tr->tr_raddr)))
-               printf(" with-ttl %d", tr->tr_rttl);
+               printf(" with-ttl %u", tr->tr_rttl);
 }
 
 static void print_mresp(register const u_char *bp, register u_int len)
 {
        register struct tr_query *tr = (struct tr_query *)(bp + 8);
 
-       printf("mresp %d: %s to %s reply-to %s", tr->tr_qid,
+       printf("mresp %u: %s to %s reply-to %s", tr->tr_qid,
                ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
                ipaddr_string(&tr->tr_raddr));
        if (IN_CLASSD(ntohl(tr->tr_raddr)))
-               printf(" with-ttl %d", tr->tr_rttl);
+               printf(" with-ttl %u", tr->tr_rttl);
 }
 
 static void
@@ -163,12 +163,12 @@ igmp_print(register const u_char *bp, re
                if (*(int *)&bp[4])
                        (void)printf(" [gaddr %s]", ipaddr_string(&bp[4]));
                if (len != 8)
-                       (void)printf(" [len %d]", len);
+                       (void)printf(" [len %u]", len);
                break;
        case 0x12:
                (void)printf("igmp report %s", ipaddr_string(&bp[4]));
                if (len != 8)
-                       (void)printf(" [len %d]", len);
+                       (void)printf(" [len %u]", len);
                break;
        case 0x16:
                (void)printf("igmp nreport %s", ipaddr_string(&bp[4]));
@@ -179,7 +179,7 @@ igmp_print(register const u_char *bp, re
        case 0x13:
                (void)printf("igmp dvmrp");
                if (len < 8)
-                       (void)printf(" [len %d]", len);
+                       (void)printf(" [len %u]", len);
                else
                        dvmrp_print(bp, len);
                break;
@@ -194,11 +194,11 @@ igmp_print(register const u_char *bp, re
                print_mtrace(bp, len);
                break;
        default:
-               (void)printf("igmp-%d", bp[0] & 0xf);
+               (void)printf("igmp-%u", bp[0] & 0xf);
                break;
        }
        if ((bp[0] >> 4) != 1)
-               (void)printf(" [v%d]", bp[0] >> 4);
+               (void)printf(" [v%u]", bp[0] >> 4);
 
        TCHECK2(bp[0], len);
        if (vflag) {
@@ -233,9 +233,9 @@ ip_printroute(const char *type, register
 
        printf(" %s{", type);
        if ((length + 1) & 3)
-               printf(" [bad length %d]", length);
+               printf(" [bad length %u]", length);
        if (ptr < 3 || ((ptr + 1) & 3) || ptr > length + 1)
-               printf(" [bad ptr %d]", cp[2]);
+               printf(" [bad ptr %u]", cp[2]);
 
        type = "";
        for (len = 3; len < length; len += 4) {
@@ -261,7 +261,7 @@ ip_optprint(register const u_char *cp, u
                tt = *cp;
                len = (tt == IPOPT_NOP || tt == IPOPT_EOL) ? 1 : cp[1];
                if (len <= 0) {
-                       printf("[|ip op len %d]", len);
+                       printf("[|ip op len %u]", len);
                        return;
                }
                if (&cp[1] >= snapend || cp + len > snapend) {
@@ -273,7 +273,7 @@ ip_optprint(register const u_char *cp, u
                case IPOPT_EOL:
                        printf(" EOL");
                        if (length > 1)
-                               printf("-%d", length - 1);
+                               printf("-%u", length - 1);
                        return;
 
                case IPOPT_NOP:
@@ -281,15 +281,15 @@ ip_optprint(register const u_char *cp, u
                        break;
 
                case IPOPT_TS:
-                       printf(" TS{%d}", len);
+                       printf(" TS{%u}", len);
                        break;
 
                case IPOPT_SECURITY:
-                       printf(" SECURITY{%d}", len);
+                       printf(" SECURITY{%u}", len);
                        break;
 
                case IPOPT_RR:
-                       printf(" RR{%d}=", len);
+                       printf(" RR{%u}=", len);
                        ip_printroute("RR", cp, len);
                        break;
 
@@ -302,7 +302,7 @@ ip_optprint(register const u_char *cp, u
                        break;
 
                default:
-                       printf(" IPOPT-%d{%d}", cp[0], len);
+                       printf(" IPOPT-%u{%u}", cp[0], len);
                        break;
                }
        }
@@ -400,14 +400,14 @@ ip_print(register const u_char *bp, regi
 
        len = ntohs(ip->ip_len);
        if (length < len) {
-               (void)printf("truncated-ip - %d bytes missing!",
+               (void)printf("truncated-ip - %u bytes missing!",
                        len - length);
                len = length;
        }
 
        hlen = ip->ip_hl * 4;
        if (hlen < sizeof(struct ip) || hlen > len) {
-               (void)printf("bad-hlen %d", hlen);
+               (void)printf("bad-hlen %u", hlen);
                goto out;
        }
 
@@ -444,7 +444,7 @@ ip_print(register const u_char *bp, regi
                case IPPROTO_ND:
                        (void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
                                ipaddr_string(&ip->ip_dst));
-                       (void)printf(" nd %d", len);
+                       (void)printf(" nd %u", len);
                        break;
 
 #ifndef IPPROTO_OSPF
@@ -586,7 +586,7 @@ ip_print(register const u_char *bp, regi
                default:
                        (void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
                                ipaddr_string(&ip->ip_dst));
-                       (void)printf(" ip-proto-%d %d", ip->ip_p, len);
+                       (void)printf(" ip-proto-%u %u", ip->ip_p, len);
                        break;
                }
        }
@@ -603,7 +603,7 @@ ip_print(register const u_char *bp, regi
                if (off & 0x1fff)
                        (void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
                                      ipaddr_string(&ip->ip_dst));
-               (void)printf(" (frag %d:%d@%d%s)", ntohs(ip->ip_id), len,
+               (void)printf(" (frag %u:%u@%u%s)", ntohs(ip->ip_id), len,
                        (off & 0x1fff) * 8,
                        (off & IP_MF)? "+" : "");
        } 
@@ -628,18 +628,18 @@ ip_print(register const u_char *bp, regi
        }
 
        if (ip->ip_ttl <= 1)
-               (void)printf(" [ttl %d]", (int)ip->ip_ttl);
+               (void)printf(" [ttl %u]", ip->ip_ttl);
 
        if (vflag) {
                char *sep = "";
 
                printf(" (");
                if (ip->ip_ttl > 1) {
-                       (void)printf("%sttl %d", sep, (int)ip->ip_ttl);
+                       (void)printf("%sttl %u", sep, ip->ip_ttl);
                        sep = ", ";
                }
                if ((off & 0x3fff) == 0) {
-                       (void)printf("%sid %d", sep, (int)ntohs(ip->ip_id));
+                       (void)printf("%sid %u", sep, ntohs(ip->ip_id));
                        sep = ", ";
                }
                (void)printf("%slen %u", sep, ntohs(ip->ip_len));
@@ -656,7 +656,7 @@ ip_print(register const u_char *bp, regi
                }
                if (hlen > sizeof(struct ip)) {
                        hlen -= sizeof(struct ip);
-                       (void)printf("%soptlen=%d", sep, hlen);
+                       (void)printf("%soptlen=%u", sep, hlen);
                        ip_optprint((u_char *)(ip + 1), hlen);
                }
                printf(")");

Reply via email to