]> The Tcpdump Group git mirrors - tcpdump/commitdiff
-Wall -Werror clean. fix uninitialized variables.
authoritojun <itojun>
Fri, 28 Apr 2000 11:34:12 +0000 (11:34 +0000)
committeritojun <itojun>
Fri, 28 Apr 2000 11:34:12 +0000 (11:34 +0000)
print-bgp.c
print-cip.c
print-tcp.c

index 5615e52bb007980379ce43bd214fb2638789fb02..872a5f4543058f4184387233c18c94832d2b7311 100644 (file)
@@ -33,7 +33,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.12 2000-01-25 09:23:10 itojun Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.13 2000-04-28 11:34:12 itojun Exp $";
 #endif
 
 #include <sys/param.h>
@@ -430,20 +430,24 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
                tlen = p[0];
                if (tlen) {
                        printf(" nexthop");
-                       if (af == AFNUM_INET)
-                               advance = 4;
-#ifdef INET6
-                       else if (af == AFNUM_INET6)
-                               advance = 16;
-#endif
-
-                       for (i = 0; i < tlen; i += advance) {
-                               if (af == AFNUM_INET)
+                       i = 0;
+                       while (i < tlen) {
+                               switch (af) {
+                               case AFNUM_INET:
                                        printf(" %s", getname(p + 1 + i));
+                                       i += sizeof(struct in_addr);
+                                       break;
 #ifdef INET6
-                               else if (af == AFNUM_INET6)
+                               case AFNUM_INET6:
                                        printf(" %s", getname6(p + 1 + i));
+                                       i += sizeof(struct in6_addr);
+                                       break;
 #endif
+                               default:
+                                       printf(" (unknown af)");
+                                       i = tlen;       /*exit loop*/
+                                       break;
+                               }
                        }
                        printf(",");
                }
@@ -462,13 +466,23 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
 
                printf(" NLRI");
                while (len - (p - dat) > 0) {
-                       if (af == AFNUM_INET)
+                       switch (af) {
+                       case AFNUM_INET:
                                advance = decode_prefix4(p, buf, sizeof(buf));
+                               printf(" %s", buf);
+                               break;
 #ifdef INET6
-                       else if (af == AFNUM_INET6)
+                       case AFNUM_INET6:
                                advance = decode_prefix6(p, buf, sizeof(buf));
+                               printf(" %s", buf);
+                               break;
 #endif
-                       printf(" %s", buf);
+                       default:
+                               printf(" (unknown af)");
+                               advance = 0;
+                               p = dat + len;
+                               break;
+                       }
 
                        p += advance;
                }
@@ -488,13 +502,23 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
 
                printf(" Withdraw");
                while (len - (p - dat) > 0) {
-                       if (af == AFNUM_INET)
+                       switch (af) {
+                       case AFNUM_INET:
                                advance = decode_prefix4(p, buf, sizeof(buf));
+                               printf(" %s", buf);
+                               break;
 #ifdef INET6
-                       else if (af == AFNUM_INET6)
+                       case AFNUM_INET6:
                                advance = decode_prefix6(p, buf, sizeof(buf));
+                               printf(" %s", buf);
+                               break;
 #endif
-                       printf(" %s", buf);
+                       default:
+                               printf(" (unknown af)");
+                               advance = 0;
+                               p = dat + len;
+                               break;
+                       }
 
                        p += advance;
                }
index 1a00cd8a8fd7d00f4c55d17fbc6abf1f37449d12..b2b6d16b1c6779af4c0ea44181dbd7bfc4c1b6fb 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.3 2000-01-09 09:59:15 assar Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.4 2000-04-28 11:34:12 itojun Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -54,38 +54,38 @@ static const char rcsid[] =
 const u_char *packetp;
 const u_char *snapend;
 
-#define RFC1483LLC_LEN 8 
+#define RFC1483LLC_LEN 8 
 
 static unsigned char rfcllc[] = {
-  0xaa,   /* DSAP: non-ISO */
-  0xaa,   /* SSAP: non-ISO */
-  0x03,   /* Ctrl: Unnumbered Information Command PDU */
-  0x00,   /* OUI: EtherType */
-  0x00,
-  0x00 };
+       0xaa,   /* DSAP: non-ISO */
+       0xaa,   /* SSAP: non-ISO */
+       0x03,   /* Ctrl: Unnumbered Information Command PDU */
+       0x00,   /* OUI: EtherType */
+       0x00,
+       0x00 };
 
 static inline void
 cip_print(register const u_char *bp, int length)
 {
-  int i;
-
-  if (memcmp(rfcllc, bp, sizeof(rfcllc))) {
-    if (qflag) {
-      for(i=0;i<RFC1483LLC_LEN;i++)
-       (void)printf("%2.2x ",bp[i]);
-    } else {
-      for(i=0;i<RFC1483LLC_LEN-2;i++)
-       (void)printf("%2.2x ",bp[i]);
-      etherproto_string(((u_short*)bp)[3]);
-    } 
-  } else {
-    if (qflag)
-      (void)printf("(null encapsulation)");
-    else {
-      (void)printf("(null encap)");
-      etherproto_string(ETHERTYPE_IP);
-    }
-  }
+       int i;
+
+       if (memcmp(rfcllc, bp, sizeof(rfcllc))) {
+               if (qflag) {
+                       for (i = 0;i < RFC1483LLC_LEN; i++)
+                       (void)printf("%2.2x ",bp[i]);
+               } else {
+                       for (i = 0;i < RFC1483LLC_LEN - 2; i++)
+                               (void)printf("%2.2x ",bp[i]);
+                       etherproto_string(((u_short*)bp)[3]);
+               
+       } else {
+               if (qflag)
+                       (void)printf("(null encapsulation)");
+               else {
+                       (void)printf("(null encap)");
+                       etherproto_string(ETHERTYPE_IP);
+               }
+       }
 }
 
 /*
@@ -111,7 +111,7 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
        }
 
        if (eflag)
-         cip_print(p, length);
+               cip_print(p, length);
 
        /*
         * Some printers want to get back at the ethernet addresses,
@@ -122,13 +122,15 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
        snapend = p + caplen;
 
        if (memcmp(rfcllc, p, sizeof(rfcllc))==0) {
-         length -= RFC1483LLC_LEN;
-         caplen -= RFC1483LLC_LEN;
-         bp = (u_short*)p;
-         p += RFC1483LLC_LEN;
-         ether_type = ntohs(bp[3]);
-       } else
-         ether_type = ETHERTYPE_IP;
+               length -= RFC1483LLC_LEN;
+               caplen -= RFC1483LLC_LEN;
+               bp = (u_short *)p;
+               p += RFC1483LLC_LEN;
+               ether_type = ntohs(bp[3]);
+       } else {
+               ether_type = ETHERTYPE_IP;
+               bp = (u_short *)p;
+       }
 
        /*
         * Is it (gag) an 802.3 encapsulation?
index 76da44d9b9963c94e37e0e3d63aeab564b89caed..7821f8c52b401f39ef7cdfdc84eac22895324790 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.64 2000-04-27 11:09:08 itojun Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.65 2000-04-28 11:34:13 itojun Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -290,7 +290,7 @@ tcp_print(register const u_char *bp, register u_int length,
                                  sizeof(th->addr)))
                                break;
 
-               if (!th->nxt || flags & TH_SYN) {
+               if (!th->nxt || (flags & TH_SYN)) {
                        /* didn't find it or new conversation */
                        if (th->nxt == NULL) {
                                th->nxt = (struct tcp_seq_hash *)
@@ -303,16 +303,19 @@ tcp_print(register const u_char *bp, register u_int length,
                                th->ack = seq, th->seq = ack - 1;
                        else
                                th->seq = seq, th->ack = ack - 1;
-               } else {
-         
-                       thseq = th->seq;
-                       thack = th->ack;
 
+               } else {
                        if (rev)
                                seq -= th->ack, ack -= th->seq;
                        else
                                seq -= th->seq, ack -= th->ack;
                }
+
+               thseq = th->seq;
+               thack = th->ack;
+       } else {
+               /*fool gcc*/
+               thseq = thack = threv = 0;
        }
        hlen = tp->th_off * 4;
        if (hlen > length) {