[ofa-general] [PATCH V1 1/1] sdplib: fix error return information
Jim Mott
jim at mellanox.com
Mon Jul 30 07:08:26 PDT 2007
Hi,
I am the new maintainer of SDP and have almost figured out what that
means. It is time to start submitting code changes for public review.
Please send comments on both the content and the style of these notices.
Fix various improper error indications returned by libsdp.so. Most of
the problems were found by unit tests and the rest by inspection looking
for similar coding issues.
Diff from OFED 1.2:
Index: ofa_user/src/userspace/libsdp/src/port.c
===================================================================
--- ofa_user.orig/src/userspace/libsdp/src/port.c 2007-07-16
23:51:00.000000000 +0300
+++ ofa_user/src/userspace/libsdp/src/port.c 2007-07-18
23:43:08.000000000 +0300
@@ -418,11 +418,13 @@ __sdp_sockaddr_to_sdp(
if ( !addr_in ) {
__sdp_log( 9, "Error __sdp_sockaddr_to_sdp: "
"provided NULL input
pointer\n" );
+ errno = EINVAL;
return -1;
}
if ( !addr_out ) {
__sdp_log( 9, "Error __sdp_sockaddr_to_sdp: "
"provided NULL output
pointer\n" );
+ errno = EINVAL;
return -1;
}
@@ -432,6 +434,7 @@ __sdp_sockaddr_to_sdp(
__sdp_log( 9, "Error __sdp_sockaddr_to_sdp: "
"provided address
length:%d < IPv4 length %d\n",
addrlen, sizeof(
struct sockaddr_in ) );
+ errno = EINVAL;
return -1;
}
@@ -443,6 +446,7 @@ __sdp_sockaddr_to_sdp(
__sdp_log( 9, "Error __sdp_sockaddr_to_sdp: "
"provided address
length:%d < IPv6 length %d\n",
addrlen,
IPV6_ADDR_IN_MIN_LEN );
+ errno = EINVAL;
return -1;
}
@@ -450,6 +454,7 @@ __sdp_sockaddr_to_sdp(
if ( !is_ipv4_embedded_in_ipv6( sin6 ) ) {
__sdp_log( 9, "Error __sdp_sockaddr_to_sdp: "
"Given IPv6 address
not an embedded IPv4\n" );
+ errno = EINVAL;
return -1;
}
memset( addr_out, 0, sizeof( struct sockaddr_in ) );
@@ -490,7 +495,8 @@ __sdp_sockaddr_to_sdp(
} else {
__sdp_log( 9, "Error __sdp_sockaddr_to_sdp: "
"address family <%d> is
unknown\n", sin->sin_family );
- return 1;
+ errno = EAFNOSUPPORT;
+ return -1;
}
return 0;
@@ -1270,7 +1276,7 @@ bind(
if ( __sdp_sockaddr_to_sdp( my_addr, addrlen, &sdp_addr,
&was_ipv6 ) ) {
__sdp_log( 9, "Error bind: failed to convert
address:%s for SDP\n",
buf );
- ret = EADDRNOTAVAIL;
+ ret = -1;
goto done;
}
#ifndef SDP_SUPPORTS_IPv6
@@ -1305,6 +1311,7 @@ bind(
__sdp_log( 9, "BIND: Failed to find
common free port\n" );
/* We cannot bind both tcp and sdp on
the same port, we will close
* the sdp and continue with tcp only */
+ goto done;
} else {
/* copy the port to the tmp address */
set_addr_port_num( ( struct sockaddr *
)&tmp_my_addr, port );
@@ -1454,7 +1461,7 @@ connect(
__sdp_log( 9,
"Error
connect: "
"failed to
convert address:%s to SDP\n", buf );
- ret = EADDRNOTAVAIL;
+ ret = -1;
goto done;
}
#ifndef SDP_SUPPORTS_IPv6
@@ -1485,7 +1492,7 @@ connect(
if ( __sdp_sockaddr_to_sdp( serv_addr, addrlen, sdp_sin,
&was_ipv6 ) ) {
__sdp_log( 9, "Error connect: "
"failed to convert to
shadow address:%s to SDP\n", buf );
- ret = EADDRNOTAVAIL;
+ ret = -1;
} else {
#ifndef SDP_SUPPORTS_IPv6
if ( was_ipv6 )
@@ -1590,7 +1597,8 @@ listen(
getsockname( fd, ( struct sockaddr * )&tmp_sin,
&tmp_sinlen ) < 0 ) {
__sdp_log( 9, "Error listen: getsockname return <%d> for
TCP socket\n",
errno );
- sret = EADDRNOTAVAIL;
+ errno = EADDRNOTAVAIL;
+ sret = -1;
goto done;
}
@@ -1623,7 +1631,7 @@ listen(
tmp_sinlen, sdp_sin, &was_ipv6 ) ) {
__sdp_log( 9, "Error listen: "
"failed to convert to
address:%s to SDP\n", buf );
- ret = EOPNOTSUPP;
+ ret = -1;
} else {
#ifndef SDP_SUPPORTS_IPv6
if ( was_ipv6 )
More information about the general
mailing list