diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-11-15 10:47:24 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-11-15 10:47:24 -0800 |
commit | 7d787482040aa327ef2345eca2e9f980ce76cc28 (patch) | |
tree | a4756446c343f763ab12c0c55b78801d3c28a3f4 /pcap-netmap.c | |
parent | 3299e855cb1cf7b6426d70e52cc51a022b9d9141 (diff) |
Add a routine to format error messages with an errno-based message at the end.
That routine will use strerror_s() or strerror_r() if available, in a
fashion that's thread-safe. Otherwise, it falls back on
pcap_strerror().
Use it in both libpcap and rpcapd.
Given that we check for errors in strerror_r(), hopefully this will
squelch warnings with newer version of GCC and GNU libc; whilst the
macOS (and other BSD-flavored?) strerror_r() always fills in a message,
that's not required by the Single UNIX Specification, as far as I can
tell, so we apparently really *do* need to check for errors.
Diffstat (limited to 'pcap-netmap.c')
-rw-r--r-- | pcap-netmap.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pcap-netmap.c b/pcap-netmap.c index 00e6e414..ee8d8b3a 100644 --- a/pcap-netmap.c +++ b/pcap-netmap.c @@ -193,9 +193,9 @@ pcap_netmap_activate(pcap_t *p) d = nm_open(p->opt.device, NULL, 0, NULL); if (d == NULL) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "netmap open: cannot access %s: %s\n", - p->opt.device, pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "netmap open: cannot access %s", + p->opt.device); pcap_cleanup_live_common(p); return (PCAP_ERROR); } |