From: Guy Harris Date: Sun, 13 Jan 2019 04:31:54 +0000 (-0800) Subject: Get rid of the last SOCK_DEBUG_MESSAGE() calls. X-Git-Tag: libpcap-1.10-bp~612 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/245ead8bc052d2dcf88c536511af895696946afd Get rid of the last SOCK_DEBUG_MESSAGE() calls. Treat a failure to get the socket buffer size as an error; we were just blithely driving on and using the variable into which the size *hadn't* been put. That means that our caller will be handed the error message; we presume they do something with it, so that we don't need to print it as a debugging message. In other cases, we already were reporting an error and providing the error message; the same applies there. --- diff --git a/pcap-rpcap.c b/pcap-rpcap.c index 61a73957..88c4e75f 100644 --- a/pcap-rpcap.c +++ b/pcap-rpcap.c @@ -1307,7 +1307,7 @@ static int pcap_startcapture_remote(pcap_t *fp) if (res == -1) { sock_geterror("pcap_startcapture_remote()", fp->errbuf, PCAP_ERRBUF_SIZE); - SOCK_DEBUG_MESSAGE(fp->errbuf); + goto error; } /* @@ -2857,7 +2857,6 @@ SOCKET pcap_remoteact_accept_ex(const char *address, const char *port, const cha { if (sock_initaddress(address, RPCAP_DEFAULT_NETPORT_ACTIVE, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1) { - SOCK_DEBUG_MESSAGE(errbuf); return (SOCKET)-2; } } @@ -2865,7 +2864,6 @@ SOCKET pcap_remoteact_accept_ex(const char *address, const char *port, const cha { if (sock_initaddress(address, port, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1) { - SOCK_DEBUG_MESSAGE(errbuf); return (SOCKET)-2; } } @@ -2873,7 +2871,6 @@ SOCKET pcap_remoteact_accept_ex(const char *address, const char *port, const cha if ((sockmain = sock_open(addrinfo, SOCKOPEN_SERVER, 1, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET) { - SOCK_DEBUG_MESSAGE(errbuf); freeaddrinfo(addrinfo); return (SOCKET)-2; } diff --git a/sockutils.h b/sockutils.h index f2c56ac6..e748662e 100644 --- a/sockutils.h +++ b/sockutils.h @@ -81,35 +81,6 @@ int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD, * \{ */ -/* - * \brief DEBUG facility: it prints an error message on the screen (stderr) - * - * This macro prints the error on the standard error stream (stderr); - * if we are working in debug mode (i.e. there is no NDEBUG defined) and we are in - * Microsoft Visual C++, the error message will appear on the MSVC console as well. - * - * When NDEBUG is defined, this macro is empty. - * - * \param msg: the message you want to print. - * - * \param expr: 'false' if you want to abort the program, 'true' it you want - * to print the message and continue. - * - * \return No return values. - */ -#ifdef NDEBUG - #define SOCK_DEBUG_MESSAGE(msg) ((void)0) -#else - #if (defined(_WIN32) && defined(_MSC_VER)) - #include /* for _CrtDbgReport */ - /* Use MessageBox(NULL, msg, "warning", MB_OK)' instead of the other calls if you want to debug a Win32 service */ - /* Remember to activate the 'allow service to interact with desktop' flag of the service */ - #define SOCK_DEBUG_MESSAGE(msg) { _CrtDbgReport(_CRT_WARN, NULL, 0, NULL, "%s\n", msg); fprintf(stderr, "%s\n", msg); } - #else - #define SOCK_DEBUG_MESSAGE(msg) { fprintf(stderr, "%s\n", msg); } - #endif -#endif - /**************************************************** * * * Exported functions / definitions *