From ffa52ab3fd961d2cf238a5ed9f28ec0fcc6dfb8a Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Tue, 10 Jul 2012 16:14:30 -0700 Subject: [PATCH] Changed the display of the contents of the error message buffer to only do so if no devices were returned at all --- sim_ether.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sim_ether.c b/sim_ether.c index 82d6a391..e49d0a5c 100644 --- a/sim_ether.c +++ b/sim_ether.c @@ -3167,11 +3167,6 @@ if (pcap_findalldevs(&alldevs, errbuf) == -1) { if (sim_log) fprintf (sim_log, msg, errbuf); } 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 */ for (i=0, dev=alldevs; dev && (i < max); dev=dev->next, ++i) { 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 */ 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 i; }