]> The Tcpdump Group git mirrors - libpcap/commitdiff
In gencode.c return PCAP_ERROR, not -1.
authorDenis Ovsienko <[email protected]>
Tue, 14 Jun 2022 11:44:47 +0000 (12:44 +0100)
committerDenis Ovsienko <[email protected]>
Tue, 14 Jun 2022 11:44:47 +0000 (12:44 +0100)
Same as in commit 2a7fcca, in pcap_compile() and pcap_compile_nopcap()
return PCAP_ERROR as that's the intended semantics.

gencode.c

index 61932901b8fcf51ee6e66e3e74beeefde9af3944..3ad47ba1b34ef6f221cece4244db458fc385a93b 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -732,7 +732,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
        if (!p->activated) {
                snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
                    "not-yet-activated pcap_t passed to pcap_compile");
-               return (-1);
+               return (PCAP_ERROR);
        }
 
 #ifdef _WIN32
@@ -780,7 +780,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
        if (cstate.snaplen == 0) {
                snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
                         "snaplen of 0 rejects all packets");
-               rc = -1;
+               rc = PCAP_ERROR;
                goto quit;
        }
 
@@ -796,7 +796,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
        pcap_set_extra(&cstate, scanner);
 
        if (init_linktype(&cstate, p) == -1) {
-               rc = -1;
+               rc = PCAP_ERROR;
                goto quit;
        }
        if (pcap_parse(scanner, &cstate) != 0) {
@@ -806,7 +806,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
 #endif
                if (cstate.e != NULL)
                        free(cstate.e);
-               rc = -1;
+               rc = PCAP_ERROR;
                goto quit;
        }
 
@@ -815,7 +815,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
                 * Catch errors reported by gen_retblk().
                 */
                if (setjmp(cstate.top_ctx)) {
-                       rc = -1;
+                       rc = PCAP_ERROR;
                        goto quit;
                }
                cstate.ic.root = gen_retblk(&cstate, cstate.snaplen);
@@ -824,14 +824,14 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
        if (optimize && !cstate.no_optimize) {
                if (bpf_optimize(&cstate.ic, p->errbuf) == -1) {
                        /* Failure */
-                       rc = -1;
+                       rc = PCAP_ERROR;
                        goto quit;
                }
                if (cstate.ic.root == NULL ||
                    (cstate.ic.root->s.code == (BPF_RET|BPF_K) && cstate.ic.root->s.k == 0)) {
                        (void)snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
                            "expression rejects all packets");
-                       rc = -1;
+                       rc = PCAP_ERROR;
                        goto quit;
                }
        }
@@ -839,7 +839,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
            cstate.ic.root, &len, p->errbuf);
        if (program->bf_insns == NULL) {
                /* Failure */
-               rc = -1;
+               rc = PCAP_ERROR;
                goto quit;
        }
        program->bf_len = len;
@@ -877,7 +877,7 @@ pcap_compile_nopcap(int snaplen_arg, int linktype_arg,
 
        p = pcap_open_dead(linktype_arg, snaplen_arg);
        if (p == NULL)
-               return (-1);
+               return (PCAP_ERROR);
        ret = pcap_compile(p, program, buf, optimize, mask);
        pcap_close(p);
        return (ret);