From: Kurt Zeilenga Date: Wed, 18 Oct 2000 00:27:31 +0000 (+0000) Subject: Use SOCKET_ERROR instead of -1 X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1713 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ce373d380077eae03f70b080c1b57b5431c7a477;p=openldap Use SOCKET_ERROR instead of -1 --- diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index 71dcd4be25..49f5a15a32 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -151,7 +151,9 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s) { int so_errno; int dummy = sizeof(so_errno); - if ( getsockopt( s, SOL_SOCKET, SO_ERROR, &so_errno, &dummy ) == -1 ) { + if ( getsockopt( s, SOL_SOCKET, SO_ERROR, &so_errno, &dummy ) + == SOCKET_ERROR ) + { return -1; } if ( so_errno ) { @@ -167,7 +169,9 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s) struct sockaddr_in sin; char ch; int dummy = sizeof(sin); - if ( getpeername( s, (struct sockaddr *) &sin, &dummy ) == -1 ) { + if ( getpeername( s, (struct sockaddr *) &sin, &dummy ) + == SOCKET_ERROR ) + { /* XXX: needs to be replace with ber_stream_read() */ read(s, &ch, 1); #ifdef HAVE_WINSOCK @@ -205,7 +209,7 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, if ( ldap_pvt_ndelay_on(ld, s) == -1 ) return ( -1 ); - if ( connect(s, sin, addrlen) == 0 ) + if ( connect(s, sin, addrlen) != SOCKET_ERROR ) { if ( ldap_pvt_ndelay_off(ld, s) == -1 ) return ( -1 ); @@ -238,13 +242,14 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, #else z, #endif - opt_tv ? &tv : NULL) == -1) + opt_tv ? &tv : NULL) == SOCKET_ERROR ) + { return ( -1 ); + } #ifdef HAVE_WINSOCK /* This means the connection failed */ - if (FD_ISSET(s, &efds)) - { + if ( FD_ISSET(s, &efds) ) { ldap_pvt_set_errno(WSAECONNREFUSED); osip_debug(ld, "ldap_pvt_connect: error on socket %d: " "errno: %d (%s)\n", s, errno, sock_errstr(errno)); @@ -310,7 +315,7 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb, do { /* we assume AF_x and PF_x are equal for all x */ s = ldap_int_socket( ld, sai->ai_family, SOCK_STREAM ); - if ( s == -1 ) { + if ( s == AC_SOCKET_INVALID ) { continue; } @@ -377,7 +382,7 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb, for ( i = 0; !use_hp || (hp->h_addr_list[i] != 0); ++i, rc = -1 ) { s = ldap_int_socket( ld, PF_INET, SOCK_STREAM ); - if ( s == -1 ) { + if ( s == AC_SOCKET_INVALID ) { /* use_hp ? continue : break; */ break; } diff --git a/libraries/libldap/os-local.c b/libraries/libldap/os-local.c index e9262b29ce..f05ceb6cb2 100644 --- a/libraries/libldap/os-local.c +++ b/libraries/libldap/os-local.c @@ -98,7 +98,9 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s) { int so_errno; int dummy = sizeof(so_errno); - if ( getsockopt( s, SOL_SOCKET, SO_ERROR, &so_errno, &dummy ) == -1 ) { + if ( getsockopt( s, SOL_SOCKET, SO_ERROR, &so_errno, &dummy ) + == SOCKET_ERROR ) + { return -1; } if ( so_errno ) { @@ -114,7 +116,9 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s) struct sockaddr_un sa; char ch; int dummy = sizeof(sa); - if ( getpeername( s, (struct sockaddr *) &sa, &dummy ) == -1 ) { + if ( getpeername( s, (struct sockaddr *) &sa, &dummy ) + == SOCKET_ERROR ) + { /* XXX: needs to be replace with ber_stream_read() */ read(s, &ch, 1); TRACE; @@ -144,10 +148,12 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr_un *sa, int async) if ( ldap_pvt_ndelay_on(ld, s) == -1 ) return ( -1 ); - if ( connect(s, (struct sockaddr *) sa, sizeof(struct sockaddr_un)) == 0 ) + if ( connect(s, (struct sockaddr *) sa, sizeof(struct sockaddr_un)) + != SOCKET_ERROR ) { - if ( ldap_pvt_ndelay_off(ld, s) == -1 ) + if ( ldap_pvt_ndelay_off(ld, s) == -1 ) { return ( -1 ); + } return ( 0 ); } @@ -162,8 +168,11 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr_un *sa, int async) FD_ZERO(&wfds); FD_SET(s, &wfds ); - if ( select(ldap_int_tblsize, z, &wfds, z, opt_tv ? &tv : NULL) == -1) + if ( select(ldap_int_tblsize, z, &wfds, z, opt_tv ? &tv : NULL) + == SOCKET_ERROR ) + { return ( -1 ); + } if ( FD_ISSET(s, &wfds) ) { if ( ldap_pvt_is_socket_ready(ld, s) == -1 ) @@ -181,12 +190,13 @@ int ldap_connect_to_path(LDAP *ld, Sockbuf *sb, const char *path, int async) { struct sockaddr_un server; - ber_socket_t s = AC_SOCKET_INVALID; + ber_socket_t s; int rc; oslocal_debug(ld, "ldap_connect_to_path\n",0,0,0); - if ( (s = ldap_pvt_socket( ld )) == -1 ) { + s = ldap_pvt_socket( ld ); + if ( s == AC_SOCKET_INVALID ) { return -1; }