X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/3dc736d939536bcd843597cb655fcba28268705c..c7b0738460b08e63a1bd15c88ef1f9599cd71a08:/tcpdump.c diff --git a/tcpdump.c b/tcpdump.c index 270f79b4..053dd540 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -1724,20 +1724,21 @@ main(int argc, char **argv) * Find the list of interfaces, and pick * the first interface. */ - if (pcap_findalldevs(&devlist, ebuf) >= 0 && - devlist != NULL) { - device = strdup(devlist->name); - pcap_freealldevs(devlist); - } + if (pcap_findalldevs(&devlist, ebuf) == -1) + error("%s", ebuf); + if (devlist == NULL) + error("no interfaces available for capture"); + device = strdup(devlist->name); + pcap_freealldevs(devlist); #else /* HAVE_PCAP_FINDALLDEVS */ /* * Use whatever interface pcap_lookupdev() * chooses. */ device = pcap_lookupdev(ebuf); -#endif if (device == NULL) error("%s", ebuf); +#endif } /*