Check errno is not 0 before testing errors

This commit is contained in:
Willem Toorop 2017-11-03 16:29:43 +01:00
parent 4508ec77fb
commit 9b019b8c6e
1 changed files with 9 additions and 7 deletions

View File

@ -137,13 +137,15 @@ const char *_getdns_strerror(int errnum);
void _getdns_perror(const char *str);
#define _getdns_errnostr() (_getdns_strerror(_getdns_socketerror()))
#define _getdns_error_wants_retry(X) ( (X) == _getdns_EINTR \
|| (X) == _getdns_EAGAIN \
|| (X) == _getdns_EWOULDBLOCK \
|| (X) == _getdns_EINPROGRESS \
|| (X) == _getdns_ENOBUFS )
#define _getdns_error_wants_retry(X) ( (X) != 0 \
&& ( (X) == _getdns_EINTR \
|| (X) == _getdns_EAGAIN \
|| (X) == _getdns_EWOULDBLOCK \
|| (X) == _getdns_EINPROGRESS \
|| (X) == _getdns_ENOBUFS ))
#define _getdns_socket_wants_retry() (_getdns_error_wants_retry(_getdns_socketerror()))
#define _getdns_resource_depletion() ( _getdns_socketerror() == _getdns_ENFILE \
|| _getdns_socketerror() == _getdns_EMFILE )
#define _getdns_resource_depletion() ( _getdns_socketerror() != 0 \
&& ( _getdns_socketerror() == _getdns_ENFILE \
|| _getdns_socketerror() == _getdns_EMFILE ))
#endif