]> The Tcpdump Group git mirrors - libpcap/commitdiff
Small tweaks to the pcap_read_npf() loop.
authorGuy Harris <[email protected]>
Tue, 14 Apr 2020 18:14:52 +0000 (11:14 -0700)
committerGuy Harris <[email protected]>
Tue, 14 Apr 2020 18:14:52 +0000 (11:14 -0700)
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.

pcap-npf.c

index 9f49794e384fdf6c05cfe16c99f39e34d97d4b04..407d64a0e5f1dc4b434b3287c826a90e9e305705 100644 (file)
@@ -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;