Use strerror() if available.
extern char *sys_errlist[];
#endif
-#ifndef HAVE_STRERROR
-#define strerror(err) \
- (err) > -1 && (err) < sys_nerr ? sys_errlist[(err)] : "unknown"
+#ifdef HAVE_STRERROR
+#define STRERROR(err) strerror(err)
+#else
+#define STRERROR(err) \
+ ((err) > -1 && (err) < sys_nerr ? sys_errlist[(err)] : "unknown")
#endif
extern char* strerror_r();
#else
# define tcp_close( s ) close( s )
# define sock_errno() errno
-# define sock_errstr() strerror(errno)
+# define sock_errstr() STRERROR(errno)
#endif /* MACOS */
#ifndef ioctl_t
Debug( LDAP_DEBUG_TRACE,
"ber_get_next on fd %d failed errno=%d (%s)\n",
- ber_pvt_sb_get_desc( conn->c_sb ), err, strerror(err) );
+ ber_pvt_sb_get_desc( conn->c_sb ), err, STRERROR(err) );
Debug( LDAP_DEBUG_TRACE,
"\t*** got %ld of %lu so far\n",
(long)(conn->c_currentber->ber_rwptr - conn->c_currentber->ber_buf),
*/
Debug( LDAP_DEBUG_CONNS, "ber_flush failed errno=%d reason=\"%s\"\n",
- err, strerror(err) );
+ err, STRERROR(err) );
if ( err != EWOULDBLOCK && err != EAGAIN ) {
connection_closing( conn );