Unsigned is always >= 0, so '> 0' and '!= 0' are identical.
This makes the tests a little clearer.
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++;
truncated = TRUE;
}
ND_PRINT("\n");
- while (length > 0) {
+ while (length != 0) {
s = GET_U_1(cp);
cp++;
length--;
if (tag == TAG_PARM_REQUEST) {
idx = 0;
- while (len > 0) {
+ while (len != 0) {
uint8_t innertag = GET_U_1(bp);
bp++;
len--;
case 'B':
/* boolean */
- while (len > 0) {
+ while (len != 0) {
uint8_t bool_value;
if (!first)
ND_PRINT(",");
case 'x':
default:
/* Bytes */
- while (len > 0) {
+ while (len != 0) {
uint8_t byte_value;
if (!first)
ND_PRINT(c == 'x' ? ":" : ".");
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));
len = 0;
break;
}
- while (len > 0) {
+ while (len != 0) {
if (!first)
ND_PRINT(",");
mask_width = GET_U_1(bp);
len = 0;
break;
}
- while (len > 0) {
+ while (len != 0) {
suboptlen = GET_U_1(bp);
bp++;
len--;
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));
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 ? */
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;
bp += 4;
len -= 4;
- while (len > 0) {
+ while (len != 0) {
if (len < 4) {
ND_PRINT("[remaining length %u < 4]", len);
goto invalid;
u_char thresh;
int ncount;
- while (len > 0) {
+ while (len != 0) {
if (len < 7) {
ND_PRINT(" [length %u < 7]", len);
goto invalid;
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;
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;
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;
{
const char *sep = "";
- while (len > 0) {
+ while (len != 0) {
uint16_t opt_class;
uint8_t opt_type;
uint8_t opt_len;
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));
}
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");
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");
break;
case ESIS_OPTION_PROTOCOLS:
- while (opli>0) {
+ while (opli != 0) {
ND_PRINT("%s (0x%02x)",
tok2str(nlpid_values,
"unknown",
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,
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;
* Now print the TLV's.
*/
- while (packet_len > 0) {
+ while (packet_len != 0) {
ND_TCHECK_2(pptr);
if (packet_len < 2)
goto trunc;
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));
tptr = tptr + 9;
/* Decode each civic address element */
- while (lci_len > 0) {
+ while (lci_len != 0) {
if (lci_len < 2) {
return hexdump;
}
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);
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);
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;
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;
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);
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);
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:
indent -= 8;
}
- while (indent > 0) {
+ while (indent != 0) {
buf[idx] = ' ';
idx++;
indent--;
/* 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
* 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;
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;
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;
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);
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;
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;
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;
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(" ");
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);
/* TLV information follows */
- while (len > 0) {
+ while (len != 0) {
/*
* Cisco specs say 2 bytes for type + 2 bytes for length;
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++;
{
u_char c;
- while (n > 0) {
+ while (n != 0) {
c = GET_U_1(s);
if (c == '\0')
break;
ND_PRINT("0s");
return;
}
- while (secs > 0) {
+ while (secs != 0) {
if (secs >= *s) {
ND_PRINT("%u%s", secs / *s, *l);
secs -= (secs / *s) * *s;