From 44b60b7c4262e78819244fbbf46726154761ffba Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Thu, 24 Jul 2008 14:03:16 -0700 Subject: [PATCH] 6725543: Compiler warnings in serviceability native code Reviewed-by: alanb --- jdk/src/share/back/ThreadReferenceImpl.c | 1 - jdk/src/share/back/transport.c | 2 +- jdk/src/share/demo/jvmti/hprof/hprof_io.c | 1 - jdk/src/share/demo/jvmti/hprof/hprof_util.c | 2 +- jdk/src/share/transport/shmem/shmemBack.c | 9 +++--- jdk/src/share/transport/shmem/shmemBase.c | 2 +- .../share/transport/socket/socketTransport.c | 19 ++++++------ jdk/src/share/transport/socket/sysSocket.h | 18 +++-------- jdk/src/solaris/transport/socket/socket_md.c | 20 ++++++------- jdk/src/windows/transport/socket/socket_md.c | 30 ++++++++----------- jdk/src/windows/transport/socket/socket_md.h | 3 ++ 11 files changed, 47 insertions(+), 60 deletions(-) diff --git a/jdk/src/share/back/ThreadReferenceImpl.c b/jdk/src/share/back/ThreadReferenceImpl.c index fc7d7434e99..a85422863ba 100644 --- a/jdk/src/share/back/ThreadReferenceImpl.c +++ b/jdk/src/share/back/ThreadReferenceImpl.c @@ -540,7 +540,6 @@ ownedMonitorsWithStackDepth(PacketInputStream *in, PacketOutputStream *out) jvmtiError error = JVMTI_ERROR_NONE; jint count = 0; - jint depth; jvmtiMonitorStackDepthInfo *monitors=NULL; error = JVMTI_FUNC_PTR(gdata->jvmti,GetOwnedMonitorStackDepthInfo) diff --git a/jdk/src/share/back/transport.c b/jdk/src/share/back/transport.c index 88e298486d2..f259a93eef3 100644 --- a/jdk/src/share/back/transport.c +++ b/jdk/src/share/back/transport.c @@ -473,7 +473,7 @@ transport_startTransport(jboolean isServer, char *name, char *address, /* * Record listener address in a system property */ - len = strlen(name) + strlen(retAddress) + 2; /* ':' and '\0' */ + len = (int)strlen(name) + (int)strlen(retAddress) + 2; /* ':' and '\0' */ prop_value = (char*)jvmtiAllocate(len); strcpy(prop_value, name); strcat(prop_value, ":"); diff --git a/jdk/src/share/demo/jvmti/hprof/hprof_io.c b/jdk/src/share/demo/jvmti/hprof/hprof_io.c index bbb7eb57304..2f679825521 100644 --- a/jdk/src/share/demo/jvmti/hprof/hprof_io.c +++ b/jdk/src/share/demo/jvmti/hprof/hprof_io.c @@ -1900,7 +1900,6 @@ static void dump_heap_segment_and_reset(jlong segment_size) { int fd; - char *last_chunk; jlong last_chunk_len; HPROF_ASSERT(gdata->heap_fd >= 0); diff --git a/jdk/src/share/demo/jvmti/hprof/hprof_util.c b/jdk/src/share/demo/jvmti/hprof/hprof_util.c index 4d5a9a52dea..6685a6cc182 100644 --- a/jdk/src/share/demo/jvmti/hprof/hprof_util.c +++ b/jdk/src/share/demo/jvmti/hprof/hprof_util.c @@ -1174,7 +1174,7 @@ add_class_fields(JNIEnv *env, ClassIndex top_cnum, ClassIndex cnum, finfo = empty_finfo; finfo.cnum = cnum; - finfo.modifiers = getFieldModifiers(klass, idlist[i]); + finfo.modifiers = (unsigned short)getFieldModifiers(klass, idlist[i]); if ( ( finfo.modifiers & JVM_ACC_STATIC ) == 0 || !skip_static_field_names ) { char *field_name; diff --git a/jdk/src/share/transport/shmem/shmemBack.c b/jdk/src/share/transport/shmem/shmemBack.c index 032969c7bea..629325be0eb 100644 --- a/jdk/src/share/transport/shmem/shmemBack.c +++ b/jdk/src/share/transport/shmem/shmemBack.c @@ -96,7 +96,8 @@ setLastError(int err, char *newmsg) { */ if (err == JDWPTRANSPORT_ERROR_IO_ERROR) { char *join_str = ": "; - int msg_len = strlen(newmsg) + strlen(join_str) + strlen(buf) + 3; + int msg_len = (int)strlen(newmsg) + (int)strlen(join_str) + + (int)strlen(buf) + 3; msg = (*callbacks->alloc)(msg_len); if (msg != NULL) { strcpy(msg, newmsg); @@ -104,7 +105,7 @@ setLastError(int err, char *newmsg) { strcat(msg, buf); } } else { - msg = (*callbacks->alloc)(strlen(newmsg)+1); + msg = (*callbacks->alloc)((int)strlen(newmsg)+1); if (msg != NULL) { strcpy(msg, newmsg); } @@ -183,7 +184,7 @@ shmemStartListening(jdwpTransportEnv* env, const char *address, char **actualAdd char *name2; rc = shmemBase_name(transport, &name); if (rc == SYS_OK) { - name2 = (callbacks->alloc)(strlen(name) + 1); + name2 = (callbacks->alloc)((int)strlen(name) + 1); if (name2 == NULL) { RETURN_ERROR(JDWPTRANSPORT_ERROR_OUT_OF_MEMORY, "out of memory"); } else { @@ -329,7 +330,7 @@ shmemGetLastError(jdwpTransportEnv* env, char **msgP) if (msg == NULL) { return JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE; } - *msgP = (*callbacks->alloc)(strlen(msg)+1); + *msgP = (*callbacks->alloc)((int)strlen(msg)+1); if (*msgP == NULL) { return JDWPTRANSPORT_ERROR_OUT_OF_MEMORY; } diff --git a/jdk/src/share/transport/shmem/shmemBase.c b/jdk/src/share/transport/shmem/shmemBase.c index a7095c8b28b..461baf647bf 100644 --- a/jdk/src/share/transport/shmem/shmemBase.c +++ b/jdk/src/share/transport/shmem/shmemBase.c @@ -167,7 +167,7 @@ setLastErrorMsg(char *newmsg) { msg = (char *)sysTlsGet(tlsIndex); if (msg == NULL) { - msg = (*callback->alloc)(strlen(newmsg)+1); + msg = (*callback->alloc)((int)strlen(newmsg)+1); if (msg != NULL) { strcpy(msg, newmsg); } diff --git a/jdk/src/share/transport/socket/socketTransport.c b/jdk/src/share/transport/socket/socketTransport.c index 2c3a1140725..705b7ef918c 100644 --- a/jdk/src/share/transport/socket/socketTransport.c +++ b/jdk/src/share/transport/socket/socketTransport.c @@ -85,7 +85,8 @@ setLastError(jdwpTransportError err, char *newmsg) { if (err == JDWPTRANSPORT_ERROR_IO_ERROR) { char *join_str = ": "; - int msg_len = strlen(newmsg) + strlen(join_str) + strlen(buf) + 3; + int msg_len = (int)strlen(newmsg) + (int)strlen(join_str) + + (int)strlen(buf) + 3; msg = (*callback->alloc)(msg_len); if (msg != NULL) { strcpy(msg, newmsg); @@ -93,7 +94,7 @@ setLastError(jdwpTransportError err, char *newmsg) { strcat(msg, buf); } } else { - msg = (*callback->alloc)(strlen(newmsg)+1); + msg = (*callback->alloc)((int)strlen(newmsg)+1); if (msg != NULL) { strcpy(msg, newmsg); } @@ -153,7 +154,7 @@ handshake(int fd, jlong timeout) { } buf = b; buf += received; - n = dbgsysRecv(fd, buf, strlen(hello)-received, 0); + n = dbgsysRecv(fd, buf, (int)strlen(hello)-received, 0); if (n == 0) { setLastError(0, "handshake failed - connection prematurally closed"); return JDWPTRANSPORT_ERROR_IO_ERROR; @@ -179,14 +180,14 @@ handshake(int fd, jlong timeout) { } } - if (dbgsysSend(fd, hello, strlen(hello), 0) != (int)strlen(hello)) { + if (dbgsysSend(fd, hello, (int)strlen(hello), 0) != (int)strlen(hello)) { RETURN_IO_ERROR("send failed during handshake"); } return JDWPTRANSPORT_ERROR_NONE; } static jdwpTransportError -parseAddress(const char *address, struct sockaddr_in *sa, UINT32 defaultHost) { +parseAddress(const char *address, struct sockaddr_in *sa, uint32_t defaultHost) { char *colon; memset((void *)sa,0,sizeof(struct sockaddr_in)); @@ -202,9 +203,9 @@ parseAddress(const char *address, struct sockaddr_in *sa, UINT32 defaultHost) { char *buf; char *hostname; u_short port; - UINT32 addr; + uint32_t addr; - buf = (*callback->alloc)(strlen(address)+1); + buf = (*callback->alloc)((int)strlen(address)+1); if (buf == NULL) { RETURN_ERROR(JDWPTRANSPORT_ERROR_OUT_OF_MEMORY, "out of memory"); } @@ -306,7 +307,7 @@ socketTransport_startListening(jdwpTransportEnv* env, const char* address, (struct sockaddr *)&sa, &len); portNum = dbgsysNetworkToHostShort(sa.sin_port); sprintf(buf, "%d", portNum); - *actualAddress = (*callback->alloc)(strlen(buf) + 1); + *actualAddress = (*callback->alloc)((int)strlen(buf) + 1); if (*actualAddress == NULL) { RETURN_ERROR(JDWPTRANSPORT_ERROR_OUT_OF_MEMORY, "out of memory"); } else { @@ -679,7 +680,7 @@ socketTransport_getLastError(jdwpTransportEnv* env, char** msgP) { if (msg == NULL) { return JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE; } - *msgP = (*callback->alloc)(strlen(msg)+1); + *msgP = (*callback->alloc)((int)strlen(msg)+1); if (*msgP == NULL) { return JDWPTRANSPORT_ERROR_OUT_OF_MEMORY; } diff --git a/jdk/src/share/transport/socket/sysSocket.h b/jdk/src/share/transport/socket/sysSocket.h index 2a0ed24dcd6..fc7ecb6b86e 100644 --- a/jdk/src/share/transport/socket/sysSocket.h +++ b/jdk/src/share/transport/socket/sysSocket.h @@ -29,14 +29,6 @@ #include "sys.h" #include "socket_md.h" -#ifdef _LP64 -typedef unsigned int UINT32; -typedef int INT32; -#else /* _LP64 */ -typedef unsigned long UINT32; -typedef long INT32; -#endif /* _LP64 */ - #define DBG_POLLIN 1 #define DBG_POLLOUT 2 @@ -44,7 +36,6 @@ typedef long INT32; #define DBG_ETIMEOUT -200 int dbgsysSocketClose(int fd); -INT32 dbgsysSocketAvailable(int fd, INT32 *pbytes); int dbgsysConnect(int fd, struct sockaddr *him, int len); int dbgsysFinishConnect(int fd, long timeout); int dbgsysAccept(int fd, struct sockaddr *him, int *len); @@ -52,18 +43,17 @@ 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 dbgsysListen(int fd, INT32 count); +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 dbgsysTimeout(int fd, INT32 timeout); struct hostent *dbgsysGetHostByName(char *hostname); int dbgsysSocket(int domain, int type, int protocol); int dbgsysBind(int fd, struct sockaddr *name, int namelen); int dbgsysSetSocketOption(int fd, jint cmd, jboolean on, jvalue value); -UINT32 dbgsysInetAddr(const char* cp); -UINT32 dbgsysHostToNetworkLong(UINT32 hostlong); +uint32_t dbgsysInetAddr(const char* cp); +uint32_t dbgsysHostToNetworkLong(uint32_t hostlong); unsigned short dbgsysHostToNetworkShort(unsigned short hostshort); -UINT32 dbgsysNetworkToHostLong(UINT32 netlong); +uint32_t dbgsysNetworkToHostLong(uint32_t netlong); unsigned short dbgsysNetworkToHostShort(unsigned short netshort); int dbgsysGetSocketName(int fd, struct sockaddr *him, int *len); int dbgsysConfigureBlocking(int fd, jboolean blocking); diff --git a/jdk/src/solaris/transport/socket/socket_md.c b/jdk/src/solaris/transport/socket/socket_md.c index f392bd9d289..84bfbe9374c 100644 --- a/jdk/src/solaris/transport/socket/socket_md.c +++ b/jdk/src/solaris/transport/socket/socket_md.c @@ -45,8 +45,8 @@ #include "sysSocket.h" int -dbgsysListen(int fd, INT32 count) { - return listen(fd, count); +dbgsysListen(int fd, int backlog) { + return listen(fd, backlog); } int @@ -131,13 +131,13 @@ dbgsysBind(int fd, struct sockaddr *name, int namelen) { return bind(fd, name, namelen); } -UINT32 +uint32_t dbgsysInetAddr(const char* cp) { - return (UINT32)inet_addr(cp); + return (uint32_t)inet_addr(cp); } -UINT32 -dbgsysHostToNetworkLong(UINT32 hostlong) { +uint32_t +dbgsysHostToNetworkLong(uint32_t hostlong) { return htonl(hostlong); } @@ -151,8 +151,8 @@ dbgsysGetSocketName(int fd, struct sockaddr *name, int *namelen) { return getsockname(fd, name, namelen); } -UINT32 -dbgsysNetworkToHostLong(UINT32 netlong) { +uint32_t +dbgsysNetworkToHostLong(uint32_t netlong) { return ntohl(netlong); } @@ -163,10 +163,10 @@ dbgsysSetSocketOption(int fd, jint cmd, jboolean on, jvalue value) if (cmd == TCP_NODELAY) { struct protoent *proto = getprotobyname("TCP"); int tcp_level = (proto == 0 ? IPPROTO_TCP: proto->p_proto); - INT32 onl = (INT32)on; + uint32_t onl = (uint32_t)on; if (setsockopt(fd, tcp_level, TCP_NODELAY, - (char *)&onl, sizeof(INT32)) < 0) { + (char *)&onl, sizeof(uint32_t)) < 0) { return SYS_ERR; } } else if (cmd == SO_LINGER) { diff --git a/jdk/src/windows/transport/socket/socket_md.c b/jdk/src/windows/transport/socket/socket_md.c index b24b2d4c84a..622b9e2da38 100644 --- a/jdk/src/windows/transport/socket/socket_md.c +++ b/jdk/src/windows/transport/socket/socket_md.c @@ -120,8 +120,8 @@ DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) * function pointer table, but our pointer should still be good. */ int -dbgsysListen(int fd, INT32 count) { - return listen(fd, (int)count); +dbgsysListen(int fd, int backlog) { + return listen(fd, backlog); } int @@ -172,7 +172,7 @@ int dbgsysFinishConnect(int fd, long timeout) { int dbgsysAccept(int fd, struct sockaddr *name, int *namelen) { - return accept(fd, name, namelen); + return (int)accept(fd, name, namelen); } int @@ -209,7 +209,7 @@ dbgsysHostToNetworkShort(unsigned short hostshort) { int dbgsysSocket(int domain, int type, int protocol) { - int fd = socket(domain, type, protocol); + int fd = (int)socket(domain, type, protocol); if (fd != SOCKET_ERROR) { SetHandleInformation((HANDLE)(UINT_PTR)fd, HANDLE_FLAG_INHERIT, FALSE); } @@ -229,12 +229,6 @@ dbgsysSocketClose(int fd) { return closesocket(fd); } -INT32 -dbgsysSocketAvailable(int fd, INT32 *pbytes) { - u_long arg = (u_long)*pbytes; - return (INT32)ioctlsocket(fd, FIONREAD, &arg); -} - /* Additions to original follow */ int @@ -243,14 +237,14 @@ dbgsysBind(int fd, struct sockaddr *name, int namelen) { } -UINT32 +uint32_t dbgsysInetAddr(const char* cp) { - return (UINT32)inet_addr(cp); + return (uint32_t)inet_addr(cp); } -UINT32 -dbgsysHostToNetworkLong(UINT32 hostlong) { - return (UINT32)htonl((u_long)hostlong); +uint32_t +dbgsysHostToNetworkLong(uint32_t hostlong) { + return (uint32_t)htonl((u_long)hostlong); } unsigned short @@ -263,9 +257,9 @@ dbgsysGetSocketName(int fd, struct sockaddr *name, int *namelen) { return getsockname(fd, name, namelen); } -UINT32 -dbgsysNetworkToHostLong(UINT32 netlong) { - return (UINT32)ntohl((u_long)netlong); +uint32_t +dbgsysNetworkToHostLong(uint32_t netlong) { + return (uint32_t)ntohl((u_long)netlong); } /* diff --git a/jdk/src/windows/transport/socket/socket_md.h b/jdk/src/windows/transport/socket/socket_md.h index 53eba1eeae4..bbf9b3439b2 100644 --- a/jdk/src/windows/transport/socket/socket_md.h +++ b/jdk/src/windows/transport/socket/socket_md.h @@ -25,3 +25,6 @@ /* Use its data structures and constants; don't make direct calls */ #include + +#define uint32_t UINT32 +