]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Replace '> 0' with '!= 0' in some unsigned expression tests
authorFrancois-Xavier Le Bail <[email protected]>
Mon, 26 Feb 2024 18:41:37 +0000 (19:41 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 28 Feb 2024 09:16:14 +0000 (10:16 +0100)
Unsigned is always >= 0, so '> 0' and '!= 0' are identical.

This makes the tests a little clearer.

26 files changed:
print-arp.c
print-ascii.c
print-bootp.c
print-cdp.c
print-cfm.c
print-dvmrp.c
print-eigrp.c
print-geneve.c
print-icmp.c
print-isoclns.c
print-ldp.c
print-lldp.c
print-lmp.c
print-nflog.c
print-ospf6.c
print-pim.c
print-radius.c
print-resp.c
print-rpki-rtr.c
print-rsvp.c
print-sflow.c
print-slow.c
print-snmp.c
print-tcp.c
print-vtp.c
util-print.c

index 67bee441ae508d73f7697bcee94e1f3af41f1f7a..3f6c02615b414cd0e082ea58980454c39769b710 100644 (file)
@@ -179,7 +179,7 @@ struct  atmarp_pkthdr {
 static int
 isnonzero(netdissect_options *ndo, const u_char *a, size_t len)
 {
-       while (len > 0) {
+       while (len != 0) {
                if (GET_U_1(a) != 0)
                        return (1);
                a++;
index 71db40dd243fa80f7f487d2d4b0959e4009f2769..4006c42ba5a62e21f2a10132bcf59076539cc2d5 100644 (file)
@@ -73,7 +73,7 @@ ascii_print(netdissect_options *ndo,
                truncated = TRUE;
        }
        ND_PRINT("\n");
-       while (length > 0) {
+       while (length != 0) {
                s = GET_U_1(cp);
                cp++;
                length--;
index 0b80bcd1ecb9426351ad696b2f725ffb0acdc052..e06943cba913291aaf3545364a349611b71f558b 100644 (file)
@@ -651,7 +651,7 @@ rfc1048_print(netdissect_options *ndo,
 
                if (tag == TAG_PARM_REQUEST) {
                        idx = 0;
-                       while (len > 0) {
+                       while (len != 0) {
                                uint8_t innertag = GET_U_1(bp);
                                bp++;
                                len--;
@@ -736,7 +736,7 @@ rfc1048_print(netdissect_options *ndo,
 
                case 'B':
                        /* boolean */
-                       while (len > 0) {
+                       while (len != 0) {
                                uint8_t bool_value;
                                if (!first)
                                        ND_PRINT(",");
@@ -762,7 +762,7 @@ rfc1048_print(netdissect_options *ndo,
                case 'x':
                default:
                        /* Bytes */
-                       while (len > 0) {
+                       while (len != 0) {
                                uint8_t byte_value;
                                if (!first)
                                        ND_PRINT(c == 'x' ? ":" : ".");
@@ -853,7 +853,7 @@ rfc1048_print(netdissect_options *ndo,
                                        break;
                                } else {
                                        ND_PRINT("%s ", tok2str(arp2str, "hardware-type %u,", type));
-                                       while (len > 0) {
+                                       while (len != 0) {
                                                if (!first)
                                                        ND_PRINT(":");
                                                ND_PRINT("%02x", GET_U_1(bp));
@@ -913,7 +913,7 @@ rfc1048_print(netdissect_options *ndo,
                                        len = 0;
                                        break;
                                }
-                               while (len > 0) {
+                               while (len != 0) {
                                        if (!first)
                                                ND_PRINT(",");
                                        mask_width = GET_U_1(bp);
@@ -968,7 +968,7 @@ rfc1048_print(netdissect_options *ndo,
                                        len = 0;
                                        break;
                                }
-                               while (len > 0) {
+                               while (len != 0) {
                                        suboptlen = GET_U_1(bp);
                                        bp++;
                                        len--;
index c66c0d11d962f43efe92f2400d72a66911713076..f8e9d7856a70a75aa56d469f713c50d15f593f33 100644 (file)
@@ -482,7 +482,7 @@ cdp_print_prefixes(netdissect_options *ndo,
 
        ND_PRINT(" IPv4 Prefixes (%u):", l / 5);
 
-       while (l > 0) {
+       while (l != 0) {
                ND_PRINT(" %u.%u.%u.%u/%u",
                         GET_U_1(p), GET_U_1(p + 1), GET_U_1(p + 2),
                         GET_U_1(p + 3), GET_U_1(p + 4));
index be32acfe5c6c2e065dcaecff4a20285564696ead..fcc2862f685fbec49b895b3377637d7fd370e1df 100644 (file)
@@ -528,7 +528,7 @@ cfm_print(netdissect_options *ndo,
     tptr += first_tlv_offset;
     tlen -= first_tlv_offset;
 
-    while (tlen > 0) {
+    while (tlen != 0) {
         cfm_tlv_header = (const struct cfm_tlv_header_t *)tptr;
 
         /* Enough to read the tlv type ? */
index 6d6d7c19b738409e14165ed4aa075f311c92fd8c..85bbde658d87be377dd4a627ca0f378c64a70c34 100644 (file)
@@ -152,7 +152,7 @@ print_report(netdissect_options *ndo,
        u_int metric, done;
        u_int i, width;
 
-       while (len > 0) {
+       while (len != 0) {
                if (len < 3) {
                        ND_PRINT(" [length %u < 3]", len);
                        goto invalid;
@@ -214,7 +214,7 @@ print_probe(netdissect_options *ndo,
 
        bp += 4;
        len -= 4;
-       while (len > 0) {
+       while (len != 0) {
                if (len < 4) {
                        ND_PRINT("[remaining length %u < 4]", len);
                        goto invalid;
@@ -238,7 +238,7 @@ print_neighbors(netdissect_options *ndo,
        u_char thresh;
        int ncount;
 
-       while (len > 0) {
+       while (len != 0) {
                if (len < 7) {
                        ND_PRINT(" [length %u < 7]", len);
                        goto invalid;
@@ -282,7 +282,7 @@ print_neighbors2(netdissect_options *ndo,
 
        ND_PRINT(" (v %u.%u):", major_version, minor_version);
 
-       while (len > 0) {
+       while (len != 0) {
                if (len < 8) {
                        ND_PRINT(" [length %u < 8]", len);
                        goto invalid;
@@ -298,7 +298,7 @@ print_neighbors2(netdissect_options *ndo,
                ncount = GET_U_1(bp);
                bp++;
                len -= 8;
-               while (--ncount >= 0 && len > 0) {
+               while (--ncount >= 0 && len != 0) {
                        if (len < 4) {
                                ND_PRINT(" [length %u < 4]", len);
                                goto invalid;
index d4eced423779acfd01385be8b288f42b246fb348..647f353bd96f05bd36a94e7ced64e0d61ec4539d 100644 (file)
@@ -279,7 +279,7 @@ eigrp_print(netdissect_options *ndo, const u_char *pptr, u_int len)
 
     tptr+=sizeof(struct eigrp_common_header);
 
-    while(tlen>0) {
+    while(tlen != 0) {
         if (tlen < sizeof(struct eigrp_tlv_header)) {
             ND_PRINT("\n\t  (only %u bytes of data)", tlen);
             goto invalid;
index 59dca93e047823de2ef2906decc6e7a314880a56..e148eb4aa866f7ffdb404e301493803807e1f94f 100644 (file)
@@ -164,7 +164,7 @@ geneve_opts_print(netdissect_options *ndo, const u_char *bp, u_int len)
 {
     const char *sep = "";
 
-    while (len > 0) {
+    while (len != 0) {
         uint16_t opt_class;
         uint8_t opt_type;
         uint8_t opt_len;
index a4564b53587b8f8e5cac1292df6dbfdba86a80c6..b446075a6628b05596887d7d90219d8bd31e5445 100644 (file)
@@ -754,7 +754,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen,
                        break;
                }
                idp = (const struct id_rdiscovery *)&dp->icmp_data;
-               while (num > 0) {
+               while (num != 0) {
                        (void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}",
                            GET_IPADDR_STRING(idp->ird_addr),
                            GET_BE_U_4(idp->ird_pref));
index 4732ec0bc5c39bc33ea648df29be0a7ad40381e6..3ac10c0d0c3e5bd7f1efda711d9c983e866d1f6c 100644 (file)
@@ -1015,7 +1015,7 @@ clnp_print(netdissect_options *ndo,
                     }
                     tptr+=nsap_offset;
                     tlen-=nsap_offset;
-                    while (tlen > 0) {
+                    while (tlen != 0) {
                             source_address_length=GET_U_1(tptr);
                             if (tlen < source_address_length+1) {
                                     ND_PRINT("\n\t    NSAP address goes past end of option");
@@ -1327,7 +1327,7 @@ esis_print(netdissect_options *ndo,
 
             ND_PRINT("\n\t  Number of Source Addresses: %u", source_address_number);
 
-            while (source_address_number > 0) {
+            while (source_address_number != 0) {
                 ND_TCHECK_1(pptr);
                if (li < 1) {
                     ND_PRINT(", bad esh/li");
@@ -1420,7 +1420,7 @@ esis_print(netdissect_options *ndo,
                 break;
 
             case ESIS_OPTION_PROTOCOLS:
-                while (opli>0) {
+                while (opli != 0) {
                     ND_PRINT("%s (0x%02x)",
                            tok2str(nlpid_values,
                                    "unknown",
@@ -1804,7 +1804,7 @@ isis_print_tlv_ip_reach(netdissect_options *ndo,
 
        tlv_ip_reach = (const struct isis_tlv_ip_reach *)cp;
 
-       while (length > 0) {
+       while (length != 0) {
                if ((size_t)length < sizeof(*tlv_ip_reach)) {
                        ND_PRINT("short IPv4 Reachability (%u vs %zu)",
                                length,
@@ -2338,7 +2338,7 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
         processed+=sublen+1;
         ND_PRINT(" (%u)", sublen);   /* print out subTLV length */
 
-        while (sublen>0) {
+        while (sublen != 0) {
             subtlvtype=GET_U_1(tptr);
             subtlvlen=GET_U_1(tptr + 1);
             tptr+=2;
@@ -2846,7 +2846,7 @@ isis_print(netdissect_options *ndo,
      * Now print the TLV's.
      */
 
-    while (packet_len > 0) {
+    while (packet_len != 0) {
        ND_TCHECK_2(pptr);
        if (packet_len < 2)
            goto trunc;
index 50d146019257763b8bd8e85e960b8dbb50aaa796..60fe010533dedebdbf172b3b0909cc499e090afd 100644 (file)
@@ -689,7 +689,7 @@ ldp_pdu_print(netdissect_options *ndo,
     tptr = pptr + sizeof(struct ldp_common_header);
     tlen = pdu_len - (sizeof(struct ldp_common_header)-4);     /* Type & Length fields not included */
 
-    while(tlen>0) {
+    while(tlen != 0) {
         /* did we capture enough for fully decoding the msg header ? */
         ND_TCHECK_LEN(tptr, sizeof(struct ldp_msg_header));
 
index 2df9aca3ac21fa31e66249f8fa728c4e82b3bfdd..33e9859c300be6867c23ae0b57cebc47fdaf9ce6 100644 (file)
@@ -1088,7 +1088,7 @@ lldp_private_tia_print(netdissect_options *ndo,
             tptr = tptr + 9;
 
             /* Decode each civic address element */
-            while (lci_len > 0) {
+            while (lci_len != 0) {
                 if (lci_len < 2) {
                     return hexdump;
                 }
index bcd69e7b242eafd989c056c54641d7bd9d75a75c..3b9bb0f20db28a6594277c6bebd4b811369fb42f 100644 (file)
@@ -477,7 +477,7 @@ lmp_print(netdissect_options *ndo,
     tptr+=sizeof(struct lmp_common_header);
     tlen-=sizeof(struct lmp_common_header);
 
-    while(tlen>0) {
+    while(tlen != 0) {
         const struct lmp_object_header *lmp_obj_header =
             (const struct lmp_object_header *)tptr;
         lmp_obj_len=GET_BE_U_2(lmp_obj_header->length);
index f90554a269ccbf3722fe40c68f199b1863695310..8db5a7a2e89aedcfa169e14cfb49ce0ce440113d 100644 (file)
@@ -169,7 +169,7 @@ nflog_if_print(netdissect_options *ndo,
        length -= NFLOG_HDR_LEN;
        caplen -= NFLOG_HDR_LEN;
 
-       while (length > 0) {
+       while (length != 0) {
                const nflog_tlv_t *tlv;
 
                ND_ICHECK_ZU(length, <, NFLOG_TLV_LEN);
index b1325364d631836a99a448535a7b1b5891c82da0..5eda0842e3e4f1587afd291a3e7657f4995abf1b 100644 (file)
@@ -661,7 +661,7 @@ ospf6_print_lsa(netdissect_options *ndo,
                        prefixes);
 
                tptr = (const uint8_t *)llsap->llsa_prefix;
-               while (prefixes > 0) {
+               while (prefixes != 0) {
                        bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
                        if (bytelen < 0)
                                goto trunc;
@@ -693,7 +693,7 @@ ospf6_print_lsa(netdissect_options *ndo,
                ND_PRINT("\n\t      Prefixes %u:", prefixes);
 
                tptr = (const uint8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix;
-               while (prefixes > 0) {
+               while (prefixes != 0) {
                        bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
                        if (bytelen < 0)
                                goto trunc;
index 2a33c1ffb6796eeb390eb93d2457cab198d16593..70948cdad5a9883c8026a60695a41e6505c804c5 100644 (file)
@@ -756,7 +756,7 @@ pimv2_print(netdissect_options *ndo,
        case PIMV2_TYPE_HELLO:
            {
                uint16_t otype, olen;
-               while (len > 0) {
+               while (len != 0) {
                        if (len < 4)
                                goto trunc;
                        otype = GET_BE_U_2(bp);
index 76a9923a8fa7506a91a103e7b3eddefa8e0a55bc..fba8b8f44c84e9077b9e3918bdf37edbb81e7cc6 100644 (file)
@@ -1317,7 +1317,7 @@ radius_attrs_print(netdissect_options *ndo,
    const char *attr_string;
    uint8_t type, len;
 
-   while (length > 0) {
+   while (length != 0) {
      ND_ICHECK_U(length, <, 2);
 
      type = GET_U_1(rad_attr->type);
index 7388a73fbd573dcb5c4779c9f720d871482a19d4..db2f1d17e1e855e729b31b7156cba4b519026c63 100644 (file)
@@ -214,7 +214,7 @@ resp_print(netdissect_options *ndo, const u_char *bp, u_int length)
     ndo->ndo_protocol = "resp";
 
     ND_PRINT(": RESP");
-    while (length > 0) {
+    while (length != 0) {
         /*
          * This block supports redis pipelining.
          * For example, multiple operations can be pipelined within the same string:
index 334720f1675b6e3f39225f2d03821f740e337691..574f3f055caf16be33cc470984fdfda4e3c411f0 100644 (file)
@@ -153,7 +153,7 @@ indent_string (u_int indent)
        indent -= 8;
     }
 
-    while (indent > 0) {
+    while (indent != 0) {
        buf[idx] = ' ';
        idx++;
        indent--;
index c577ec1c595cdf592e80a9ab35293483a293bc0d..0a289ee66d1b68f66b1d5c41c6af040542ee0233 100644 (file)
@@ -1236,7 +1236,7 @@ rsvp_obj_print(netdissect_options *ndo,
 
                /* read variable length subobjects */
                total_subobj_len = obj_tlen;
-                while(total_subobj_len > 0) {
+                while(total_subobj_len != 0) {
                     /* If RFC 3476 Section 3.1 defined that a sub-object of the
                      * GENERALIZED_UNI RSVP object must have the Length field as
                      * a multiple of 4, instead of the check below it would be
@@ -1965,7 +1965,7 @@ rsvp_print(netdissect_options *ndo,
          * Bundle messages may not contain bundle submessages, so we don't
          * need to handle bundle submessages specially.
          */
-        while(tlen > 0) {
+        while(tlen != 0) {
             const u_char *subpptr=tptr, *subtptr;
             u_short subplen, subtlen;
 
index 0b6a832e4fdc1073e0e40a4347cfb890a55f6b7d..3934cd9a4c8d88e6c295626ff579cd062ae3c4ce 100644 (file)
@@ -494,7 +494,7 @@ sflow_print_counter_records(netdissect_options *ndo,
     tptr = pointer;
     tlen = len;
 
-    while (nrecords > 0) {
+    while (nrecords != 0) {
        /* do we have the "header?" */
        if (tlen < sizeof(struct sflow_counter_record_t))
            return 1;
@@ -683,7 +683,7 @@ sflow_print_flow_records(netdissect_options *ndo,
     tptr = pointer;
     tlen = len;
 
-    while (nrecords > 0) {
+    while (nrecords != 0) {
        /* do we have the "header?" */
        if (tlen < sizeof(struct sflow_flow_record_t))
            return 1;
@@ -896,7 +896,7 @@ sflow_print(netdissect_options *ndo,
         tptr += sizeof(struct sflow_v6_datagram_t);
         tlen -= sizeof(struct sflow_v6_datagram_t);
     }
-    while (nsamples > 0 && tlen > 0) {
+    while (nsamples != 0 && tlen != 0) {
         sflow_sample = (const struct sflow_sample_header *)tptr;
 
         sflow_sample_type = (GET_BE_U_4(sflow_sample->format)&0x0FFF);
index 8a75edcc99aeef5d4535773b5b21dc807c05bfba..f2773401976fa076cfdf5e417675b4539301a19e 100644 (file)
@@ -355,7 +355,7 @@ slow_marker_lacp_print(netdissect_options *ndo,
         const struct marker_tlv_marker_info_t *marker_tlv_marker_info;
     } tlv_ptr;
 
-    while(tlen>0) {
+    while(tlen != 0) {
         /* is the packet big enough to include the tlv header ? */
         if (tlen < sizeof(struct tlv_header_t))
             goto tooshort;
@@ -525,7 +525,7 @@ slow_oam_print(netdissect_options *ndo,
 
     switch (code) {
     case SLOW_OAM_CODE_INFO:
-        while (tlen > 0) {
+        while (tlen != 0) {
             ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr;
             if (tlen < sizeof(*ptr.slow_oam_tlv_header))
                 goto tooshort;
@@ -622,7 +622,7 @@ slow_oam_print(netdissect_options *ndo,
         tptr += 2;
 
         /* TLVs */
-        while (tlen > 0) {
+        while (tlen != 0) {
             ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr;
             if (tlen < sizeof(*ptr.slow_oam_tlv_header))
                 goto tooshort;
index d975b4277cb954ea9827898f5fbb3060ef22d4fc..4958791393f45552c3dc7fb1f2008b9f69ceb48e 100644 (file)
@@ -847,7 +847,7 @@ asn1_decode(u_char *p, u_int length)
        struct be elem;
        int i = 0;
 
-       while (i >= 0 && length > 0) {
+       while (i >= 0 && length != 0) {
                i = asn1_parse(ndo, p, length, &elem);
                if (i >= 0) {
                        ND_PRINT(" ");
index 4f91b7622805dfb89a6d4c2d85aa49125220ac9b..308915bcb7e1610b19d53b10a41e45be3ecf90fe 100644 (file)
@@ -445,7 +445,7 @@ tcp_print(netdissect_options *ndo,
                 hlen -= sizeof(*tp);
                 cp = (const u_char *)tp + sizeof(*tp);
                 ND_PRINT(", options [");
-                while (hlen > 0) {
+                while (hlen != 0) {
                         if (ch != '\0')
                                 ND_PRINT("%c", ch);
                         opt = GET_U_1(cp);
index 1637db661d0f0b8a1f046797479eb6b7d086afc1..cfb62dac98ccd023423ebad697714d023d0b780f 100644 (file)
@@ -271,7 +271,7 @@ vtp_print(netdissect_options *ndo,
 
             /* TLV information follows */
 
-            while (len > 0) {
+            while (len != 0) {
 
                 /*
                  * Cisco specs say 2 bytes for type + 2 bytes for length;
index b82576749cf623142074a1cf2e28b1bb2d91bb8c..49126bd6723da7ec008c6aa674b0a9c29ab96e36 100644 (file)
@@ -181,7 +181,7 @@ nd_printn(netdissect_options *ndo,
 void
 nd_printjn(netdissect_options *ndo, const u_char *s, u_int n)
 {
-       while (n > 0) {
+       while (n != 0) {
                fn_print_char(ndo, GET_U_1(s));
                n--;
                s++;
@@ -200,7 +200,7 @@ nd_printjnp(netdissect_options *ndo, const u_char *s, u_int n)
 {
        u_char c;
 
-       while (n > 0) {
+       while (n != 0) {
                c = GET_U_1(s);
                if (c == '\0')
                        break;
@@ -376,7 +376,7 @@ unsigned_relts_print(netdissect_options *ndo,
                ND_PRINT("0s");
                return;
        }
-       while (secs > 0) {
+       while (secs != 0) {
                if (secs >= *s) {
                        ND_PRINT("%u%s", secs / *s, *l);
                        secs -= (secs / *s) * *s;