6725543: Compiler warnings in serviceability native code
authorohair
Thu, 24 Jul 2008 14:03:16 -0700
changeset 896 5c02031316bf
parent 895 67f1dc69ad10
child 897 2a9d890925bb
6725543: Compiler warnings in serviceability native code Reviewed-by: alanb
jdk/src/share/back/ThreadReferenceImpl.c
jdk/src/share/back/transport.c
jdk/src/share/demo/jvmti/hprof/hprof_io.c
jdk/src/share/demo/jvmti/hprof/hprof_util.c
jdk/src/share/transport/shmem/shmemBack.c
jdk/src/share/transport/shmem/shmemBase.c
jdk/src/share/transport/socket/socketTransport.c
jdk/src/share/transport/socket/sysSocket.h
jdk/src/solaris/transport/socket/socket_md.c
jdk/src/windows/transport/socket/socket_md.c
jdk/src/windows/transport/socket/socket_md.h
--- a/jdk/src/share/back/ThreadReferenceImpl.c	Thu Jul 24 12:46:41 2008 +0100
+++ b/jdk/src/share/back/ThreadReferenceImpl.c	Thu Jul 24 14:03:16 2008 -0700
@@ -540,7 +540,6 @@
 
         jvmtiError error = JVMTI_ERROR_NONE;
         jint count = 0;
-        jint depth;
         jvmtiMonitorStackDepthInfo *monitors=NULL;
 
         error = JVMTI_FUNC_PTR(gdata->jvmti,GetOwnedMonitorStackDepthInfo)
--- a/jdk/src/share/back/transport.c	Thu Jul 24 12:46:41 2008 +0100
+++ b/jdk/src/share/back/transport.c	Thu Jul 24 14:03:16 2008 -0700
@@ -473,7 +473,7 @@
         /*
          * 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, ":");
--- a/jdk/src/share/demo/jvmti/hprof/hprof_io.c	Thu Jul 24 12:46:41 2008 +0100
+++ b/jdk/src/share/demo/jvmti/hprof/hprof_io.c	Thu Jul 24 14:03:16 2008 -0700
@@ -1900,7 +1900,6 @@
 dump_heap_segment_and_reset(jlong segment_size)
 {
     int   fd;
-    char *last_chunk;
     jlong last_chunk_len;
 
     HPROF_ASSERT(gdata->heap_fd >= 0);
--- a/jdk/src/share/demo/jvmti/hprof/hprof_util.c	Thu Jul 24 12:46:41 2008 +0100
+++ b/jdk/src/share/demo/jvmti/hprof/hprof_util.c	Thu Jul 24 14:03:16 2008 -0700
@@ -1174,7 +1174,7 @@
 
         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;
--- a/jdk/src/share/transport/shmem/shmemBack.c	Thu Jul 24 12:46:41 2008 +0100
+++ b/jdk/src/share/transport/shmem/shmemBack.c	Thu Jul 24 14:03:16 2008 -0700
@@ -96,7 +96,8 @@
      */
     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 @@
             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 @@
         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 @@
     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;
     }
--- a/jdk/src/share/transport/shmem/shmemBase.c	Thu Jul 24 12:46:41 2008 +0100
+++ b/jdk/src/share/transport/shmem/shmemBase.c	Thu Jul 24 14:03:16 2008 -0700
@@ -167,7 +167,7 @@
 
     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);
         }
--- a/jdk/src/share/transport/socket/socketTransport.c	Thu Jul 24 12:46:41 2008 +0100
+++ b/jdk/src/share/transport/socket/socketTransport.c	Thu Jul 24 14:03:16 2008 -0700
@@ -85,7 +85,8 @@
 
     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 @@
             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 @@
         }
         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 @@
         }
     }
 
-    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 @@
         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 @@
                                (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 @@
     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;
     }
--- a/jdk/src/share/transport/socket/sysSocket.h	Thu Jul 24 12:46:41 2008 +0100
+++ b/jdk/src/share/transport/socket/sysSocket.h	Thu Jul 24 14:03:16 2008 -0700
@@ -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 @@
 #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 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);
--- a/jdk/src/solaris/transport/socket/socket_md.c	Thu Jul 24 12:46:41 2008 +0100
+++ b/jdk/src/solaris/transport/socket/socket_md.c	Thu Jul 24 14:03:16 2008 -0700
@@ -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 @@
     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 @@
     return getsockname(fd, name, namelen);
 }
 
-UINT32
-dbgsysNetworkToHostLong(UINT32 netlong) {
+uint32_t
+dbgsysNetworkToHostLong(uint32_t netlong) {
     return ntohl(netlong);
 }
 
@@ -163,10 +163,10 @@
     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) {
--- a/jdk/src/windows/transport/socket/socket_md.c	Thu Jul 24 12:46:41 2008 +0100
+++ b/jdk/src/windows/transport/socket/socket_md.c	Thu Jul 24 14:03:16 2008 -0700
@@ -120,8 +120,8 @@
  * 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
 dbgsysAccept(int fd, struct sockaddr *name, int *namelen) {
-    return accept(fd, name, namelen);
+    return (int)accept(fd, name, namelen);
 }
 
 int
@@ -209,7 +209,7 @@
 
 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 @@
     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 @@
 }
 
 
-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 @@
     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);
 }
 
 /*
--- a/jdk/src/windows/transport/socket/socket_md.h	Thu Jul 24 12:46:41 2008 +0100
+++ b/jdk/src/windows/transport/socket/socket_md.h	Thu Jul 24 14:03:16 2008 -0700
@@ -25,3 +25,6 @@
 /* Use its data structures and constants; don't make direct calls */
 
 #include <winsock2.h>
+
+#define uint32_t UINT32
+