That's what should always be used to check whether a packet count
argument means "give me all the packets you have".
Check it first, so we don't compare the packet count against a zero or
negative value.
(cherry picked from commit
56c60dd660297b5cf02afcb9fdc4f92689de0353)
if ((fcode = p->fcode.bf_insns) == NULL ||
pcap_filter(fcode, data, h.len, h.caplen)) {
(*callback)(user, &h, data);
- if (++n >= cnt && cnt > 0)
+ n++; /* count the packet */
+ if (!PACKET_COUNT_IS_UNLIMITED(cnt) && n >= cnt)
break;
}
}