8005120: Compiler warnings in socket transport native code
Reviewed-by: chegar, dsamersoff
--- a/jdk/src/share/transport/socket/socketTransport.c Thu Jan 17 15:09:46 2013 -0500
+++ b/jdk/src/share/transport/socket/socketTransport.c Fri Jan 18 17:34:40 2013 +0000
@@ -304,7 +304,7 @@
{
char buf[20];
- int len = sizeof(sa);
+ socklen_t len = sizeof(sa);
jint portNum;
err = dbgsysGetSocketName(serverSocketFD,
(struct sockaddr *)&sa, &len);
@@ -324,7 +324,8 @@
static jdwpTransportError JNICALL
socketTransport_accept(jdwpTransportEnv* env, jlong acceptTimeout, jlong handshakeTimeout)
{
- int socketLen, err;
+ socklen_t socketLen;
+ int err;
struct sockaddr_in socket;
jlong startTime = (jlong)0;
@@ -508,7 +509,7 @@
if (dbgsysSocketClose(fd) < 0) {
/*
* close failed - it's pointless to restore socketFD here because
- * any subsequent close will likely fail aswell.
+ * any subsequent close will likely fail as well.
*/
RETURN_IO_ERROR("close failed");
}
--- a/jdk/src/share/transport/socket/sysSocket.h Thu Jan 17 15:09:46 2013 -0500
+++ b/jdk/src/share/transport/socket/sysSocket.h Fri Jan 18 17:34:40 2013 +0000
@@ -34,28 +34,29 @@
#define DBG_EINPROGRESS -150
#define DBG_ETIMEOUT -200
+#ifdef WIN32
+typedef int socklen_t;
+#endif
int dbgsysSocketClose(int fd);
-int dbgsysConnect(int fd, struct sockaddr *him, int len);
-int dbgsysFinishConnect(int fd, long timeout);
-int dbgsysAccept(int fd, struct sockaddr *him, int *len);
-int dbgsysSendTo(int fd, char *buf, int len, int flags, struct sockaddr *to,
- int tolen);
-int dbgsysRecvFrom(int fd, char *buf, int nbytes, int flags,
- struct sockaddr *from, int *fromlen);
+int dbgsysConnect(int fd, struct sockaddr *him, socklen_t len);
+int dbgsysFinishConnect(int fd, int timeout);
+int dbgsysAccept(int fd, struct sockaddr *him, socklen_t *len);
+int dbgsysSendTo(int fd, char *buf, size_t len, int flags, struct sockaddr *to, socklen_t tolen);
+int dbgsysRecvFrom(int fd, char *buf, size_t nBytes, int flags, struct sockaddr *from, socklen_t *fromlen);
int dbgsysListen(int fd, int backlog);
-int dbgsysRecv(int fd, char *buf, int nBytes, int flags);
-int dbgsysSend(int fd, char *buf, int nBytes, int flags);
+int dbgsysRecv(int fd, char *buf, size_t nBytes, int flags);
+int dbgsysSend(int fd, char *buf, size_t nBytes, int flags);
struct hostent *dbgsysGetHostByName(char *hostname);
int dbgsysSocket(int domain, int type, int protocol);
-int dbgsysBind(int fd, struct sockaddr *name, int namelen);
+int dbgsysBind(int fd, struct sockaddr *name, socklen_t namelen);
int dbgsysSetSocketOption(int fd, jint cmd, jboolean on, jvalue value);
uint32_t dbgsysInetAddr(const char* cp);
uint32_t dbgsysHostToNetworkLong(uint32_t hostlong);
unsigned short dbgsysHostToNetworkShort(unsigned short hostshort);
uint32_t dbgsysNetworkToHostLong(uint32_t netlong);
unsigned short dbgsysNetworkToHostShort(unsigned short netshort);
-int dbgsysGetSocketName(int fd, struct sockaddr *him, int *len);
+int dbgsysGetSocketName(int fd, struct sockaddr *him, socklen_t *len);
int dbgsysConfigureBlocking(int fd, jboolean blocking);
int dbgsysPoll(int fd, jboolean rd, jboolean wr, long timeout);
int dbgsysGetLastIOError(char *buf, jint size);
--- a/jdk/src/solaris/transport/socket/socket_md.c Thu Jan 17 15:09:46 2013 -0500
+++ b/jdk/src/solaris/transport/socket/socket_md.c Fri Jan 18 17:34:40 2013 +0000
@@ -49,7 +49,7 @@
}
int
-dbgsysConnect(int fd, struct sockaddr *name, int namelen) {
+dbgsysConnect(int fd, struct sockaddr *name, socklen_t namelen) {
int rv = connect(fd, name, namelen);
if (rv < 0 && (errno == EINPROGRESS || errno == EINTR)) {
return DBG_EINPROGRESS;
@@ -59,7 +59,7 @@
}
int
-dbgsysFinishConnect(int fd, long timeout) {
+dbgsysFinishConnect(int fd, int timeout) {
int rv = dbgsysPoll(fd, 0, 1, timeout);
if (rv == 0) {
return DBG_ETIMEOUT;
@@ -71,7 +71,7 @@
}
int
-dbgsysAccept(int fd, struct sockaddr *name, int *namelen) {
+dbgsysAccept(int fd, struct sockaddr *name, socklen_t *namelen) {
int rv;
for (;;) {
rv = accept(fd, name, namelen);
@@ -85,8 +85,8 @@
}
int
-dbgsysRecvFrom(int fd, char *buf, int nBytes,
- int flags, struct sockaddr *from, int *fromlen) {
+dbgsysRecvFrom(int fd, char *buf, size_t nBytes,
+ int flags, struct sockaddr *from, socklen_t *fromlen) {
int rv;
do {
rv = recvfrom(fd, buf, nBytes, flags, from, fromlen);
@@ -96,8 +96,8 @@
}
int
-dbgsysSendTo(int fd, char *buf, int len,
- int flags, struct sockaddr *to, int tolen) {
+dbgsysSendTo(int fd, char *buf, size_t len,
+ int flags, struct sockaddr *to, socklen_t tolen) {
int rv;
do {
rv = sendto(fd, buf, len, flags, to, tolen);
@@ -107,7 +107,7 @@
}
int
-dbgsysRecv(int fd, char *buf, int nBytes, int flags) {
+dbgsysRecv(int fd, char *buf, size_t nBytes, int flags) {
int rv;
do {
rv = recv(fd, buf, nBytes, flags);
@@ -117,7 +117,7 @@
}
int
-dbgsysSend(int fd, char *buf, int nBytes, int flags) {
+dbgsysSend(int fd, char *buf, size_t nBytes, int flags) {
int rv;
do {
rv = send(fd, buf, nBytes, flags);
@@ -151,7 +151,7 @@
}
int
-dbgsysBind(int fd, struct sockaddr *name, int namelen) {
+dbgsysBind(int fd, struct sockaddr *name, socklen_t namelen) {
return bind(fd, name, namelen);
}
@@ -171,7 +171,7 @@
}
int
-dbgsysGetSocketName(int fd, struct sockaddr *name, int *namelen) {
+dbgsysGetSocketName(int fd, struct sockaddr *name, socklen_t *namelen) {
return getsockname(fd, name, namelen);
}
--- a/jdk/src/windows/transport/socket/socket_md.c Thu Jan 17 15:09:46 2013 -0500
+++ b/jdk/src/windows/transport/socket/socket_md.c Fri Jan 18 17:34:40 2013 +0000
@@ -125,7 +125,7 @@
}
int
-dbgsysConnect(int fd, struct sockaddr *name, int namelen) {
+dbgsysConnect(int fd, struct sockaddr *name, socklen_t namelen) {
int rv = connect(fd, name, namelen);
if (rv == SOCKET_ERROR) {
if (WSAGetLastError() == WSAEINPROGRESS || WSAGetLastError() == WSAEWOULDBLOCK) {
@@ -135,7 +135,7 @@
return rv;
}
-int dbgsysFinishConnect(int fd, long timeout) {
+int dbgsysFinishConnect(int fd, int timeout) {
int rv;
struct timeval t;
fd_set wr, ex;
@@ -171,30 +171,30 @@
int
-dbgsysAccept(int fd, struct sockaddr *name, int *namelen) {
+dbgsysAccept(int fd, struct sockaddr *name, socklen_t *namelen) {
return (int)accept(fd, name, namelen);
}
int
-dbgsysRecvFrom(int fd, char *buf, int nBytes,
- int flags, struct sockaddr *from, int *fromlen) {
- return recvfrom(fd, buf, nBytes, flags, from, fromlen);
+dbgsysRecvFrom(int fd, char *buf, size_t nBytes,
+ int flags, struct sockaddr *from, socklen_t *fromlen) {
+ return recvfrom(fd, buf, (int)nBytes, flags, from, fromlen);
}
int
-dbgsysSendTo(int fd, char *buf, int len,
- int flags, struct sockaddr *to, int tolen) {
- return sendto(fd, buf, len, flags, to, tolen);
+dbgsysSendTo(int fd, char *buf, size_t len,
+ int flags, struct sockaddr *to, socklen_t tolen) {
+ return sendto(fd, buf, (int)len, flags, to, tolen);
}
int
-dbgsysRecv(int fd, char *buf, int nBytes, int flags) {
- return recv(fd, buf, nBytes, flags);
+dbgsysRecv(int fd, char *buf, size_t nBytes, int flags) {
+ return recv(fd, buf, (int) nBytes, flags);
}
int
-dbgsysSend(int fd, char *buf, int nBytes, int flags) {
- return send(fd, buf, nBytes, flags);
+dbgsysSend(int fd, char *buf, size_t nBytes, int flags) {
+ return send(fd, buf, (int)nBytes, flags);
}
struct hostent *
@@ -232,7 +232,7 @@
/* Additions to original follow */
int
-dbgsysBind(int fd, struct sockaddr *name, int namelen) {
+dbgsysBind(int fd, struct sockaddr *name, socklen_t namelen) {
return bind(fd, name, namelen);
}
@@ -253,7 +253,7 @@
}
int
-dbgsysGetSocketName(int fd, struct sockaddr *name, int *namelen) {
+dbgsysGetSocketName(int fd, struct sockaddr *name, socklen_t *namelen) {
return getsockname(fd, name, namelen);
}
@@ -426,7 +426,7 @@
}
#define FT2INT64(ft) \
- ((long)(ft).dwHighDateTime << 32 | (long)(ft).dwLowDateTime)
+ ((INT64)(ft).dwHighDateTime << 32 | (INT64)(ft).dwLowDateTime)
long
dbgsysCurrentTimeMillis() {