From: Guy Harris Date: Tue, 14 Apr 2020 18:14:52 +0000 (-0700) Subject: Small tweaks to the pcap_read_npf() loop. X-Git-Tag: libpcap-1.10-bp~217 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/c09bbf39a614f71028e6e1ec59b5d85fa6083249 Small tweaks to the pcap_read_npf() loop. Set a variable just before we start using it, making it a bit clearer that packet counting is being done in that loop. After an assignment, test the assigned-to variable; this makes it a bit more like the equivalent loop in pcap-bpf.c. --- diff --git a/pcap-npf.c b/pcap-npf.c index 9f49794e..407d64a0 100644 --- a/pcap-npf.c +++ b/pcap-npf.c @@ -489,13 +489,13 @@ pcap_read_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user) { PACKET Packet; int cc; - int n = 0; + int n; register u_char *bp, *ep; u_char *datap; struct pcap_win *pw = p->priv; cc = p->cc; - if (p->cc == 0) { + if (cc == 0) { /* * Has "pcap_breakloop()" been called? */ @@ -565,6 +565,7 @@ pcap_read_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user) * Loop through each packet. */ #define bhp ((struct bpf_hdr *)bp) + n = 0; ep = bp + cc; for (;;) { register u_int caplen, hdrlen;