Changed the display of the contents of the error message buffer to only do so if no devices were returned at all

This commit is contained in:
Mark Pizzolato 2012-07-10 16:14:30 -07:00
parent f66175beea
commit ffa52ab3fd

View file

@ -3167,11 +3167,6 @@ if (pcap_findalldevs(&alldevs, errbuf) == -1) {
if (sim_log) fprintf (sim_log, msg, errbuf); if (sim_log) fprintf (sim_log, msg, errbuf);
} }
else { else {
if (errbuf[0]) {
char* msg = "Eth: pcap_findalldevs warning: %s\r\n";
printf (msg, errbuf);
if (sim_log) fprintf (sim_log, msg, errbuf);
}
/* copy device list into the passed structure */ /* copy device list into the passed structure */
for (i=0, dev=alldevs; dev && (i < max); dev=dev->next, ++i) { for (i=0, dev=alldevs; dev && (i < max); dev=dev->next, ++i) {
if ((dev->flags & PCAP_IF_LOOPBACK) || (!strcmp("any", dev->name))) continue; if ((dev->flags & PCAP_IF_LOOPBACK) || (!strcmp("any", dev->name))) continue;
@ -3190,6 +3185,13 @@ else {
/* Add any host specific devices and/or validate those already found */ /* Add any host specific devices and/or validate those already found */
i = eth_host_devices(i, max, list); i = eth_host_devices(i, max, list);
/* If no devices were found and an error message was left in the buffer, display it */
if ((i == 0) && (errbuf[0])) {
char* msg = "Eth: pcap_findalldevs warning: %s\r\n";
printf (msg, errbuf);
if (sim_log) fprintf (sim_log, msg, errbuf);
}
/* return device count */ /* return device count */
return i; return i;
} }