United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6725543 Compiler warnings in serviceability native code
JDK-6725543 : Compiler warnings in serviceability native code

Details
Type:
Bug
Submit Date:
2008-07-14
Status:
Closed
Updated Date:
2011-04-19
Project Name:
JDK
Resolved Date:
2011-04-19
Component:
core-svc
OS:
generic
Sub-Component:
tools
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:

Sub Tasks

Description
Compiler warnings in serviceability code: (see logs at /java/re/jdk/7/promotes/latest/logs/build*.log)

../../../src\share\back\ThreadReferenceImpl.c(543) : warning C4101: 'depth' : unreferenced local variable

../../../src\share\back\transport.c(476) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data

../../../../src\share\transport\shmem\shmemBack.c(107) : warning C4267: 'function' : conversion from 'size_t' to 'jint', possible loss of data
../../../../src\share\transport\shmem\shmemBack.c(186) : warning C4267: 'function' : conversion from 'size_t' to 'jint', possible loss of data
../../../../src\share\transport\shmem\shmemBack.c(332) : warning C4267: 'function' : conversion from 'size_t' to 'jint', possible loss of data
../../../../src\share\transport\shmem\shmemBack.c(99) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data

../../../../src\share\transport\shmem\shmemBase.c(170) : warning C4267: 'function' : conversion from 'size_t' to 'jint', possible loss of data

../../../../src\share\transport\socket\socketTransport.c(156) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
../../../../src\share\transport\socket\socketTransport.c(182) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
../../../../src\share\transport\socket\socketTransport.c(207) : warning C4267: 'function' : conversion from 'size_t' to 'jint', possible loss of data
../../../../src\share\transport\socket\socketTransport.c(309) : warning C4267: 'function' : conversion from 'size_t' to 'jint', possible loss of data
../../../../src\share\transport\socket\socketTransport.c(682) : warning C4267: 'function' : conversion from 'size_t' to 'jint', possible loss of data
../../../../src\share\transport\socket\socketTransport.c(88) : warning C4267: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
../../../../src\share\transport\socket\socketTransport.c(96) : warning C4267: 'function' : conversion from 'size_t' to 'jint', possible loss of data

../../../../src\share\transport\socket\sysSocket.h(36) : warning C4142: benign redefinition of type
../../../../src\share\transport\socket\sysSocket.h(37) : warning C4142: benign redefinition of type

../../../../src\windows\transport\socket\socket_md.c(175) : warning C4244: 'return' : conversion from 'SOCKET' to 'int', possible loss of data
../../../../src\windows\transport\socket\socket_md.c(212) : warning C4244: 'initializing' : conversion from 'SOCKET' to 'int', possible loss of data

../../../src\share\demo\jvmti\hprof\hprof_io.c(1903) : warning C4101: 'last_chunk' : unreferenced local variable

../../../src\share\demo\jvmti\hprof\hprof_util.c(1177) : warning C4244: '=' : conversion from 'jint' to 'unsigned short', possible loss of data

                                    

Comments
EVALUATION

Fixes in progress.
                                     
2008-07-21
SUGGESTED FIX

--- old/src/share/back/ThreadReferenceImpl.c	Mon Jul 21 10:39:19 2008
+++ new/src/share/back/ThreadReferenceImpl.c	Mon Jul 21 10:39:19 2008
@@ -540,7 +540,6 @@
 
         jvmtiError error = JVMTI_ERROR_NONE;
         jint count = 0;
-        jint depth;
         jvmtiMonitorStackDepthInfo *monitors=NULL;
 
         error = JVMTI_FUNC_PTR(gdata->jvmti,GetOwnedMonitorStackDepthInfo)
--- old/src/share/back/transport.c	Mon Jul 21 10:39:21 2008
+++ new/src/share/back/transport.c	Mon Jul 21 10:39:20 2008
@@ -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, ":");
--- old/src/share/demo/jvmti/hprof/hprof_io.c	Mon Jul 21 10:39:22 2008
+++ new/src/share/demo/jvmti/hprof/hprof_io.c	Mon Jul 21 10:39:22 2008
@@ -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);
--- old/src/share/demo/jvmti/hprof/hprof_util.c	Mon Jul 21 10:39:23 2008
+++ new/src/share/demo/jvmti/hprof/hprof_util.c	Mon Jul 21 10:39:23 2008
@@ -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;
--- old/src/share/transport/shmem/shmemBack.c	Mon Jul 21 10:39:25 2008
+++ new/src/share/transport/shmem/shmemBack.c	Mon Jul 21 10:39:24 2008
@@ -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;
     }
--- old/src/share/transport/shmem/shmemBase.c	Mon Jul 21 10:39:26 2008
+++ new/src/share/transport/shmem/shmemBase.c	Mon Jul 21 10:39:26 2008
@@ -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);
         }
--- old/src/share/transport/socket/socketTransport.c	Mon Jul 21 10:39:27 2008
+++ new/src/share/transport/socket/socketTransport.c	Mon Jul 21 10:39:27 2008
@@ -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,7 +180,7 @@
         }
     }
 
-    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;
@@ -186,7 +187,7 @@
 }
 
 static jdwpTransportError
-parseAddress(const char *address, struct sockaddr_in *sa, UINT32 defaultHost) {
+parseAddress(const char *address, struct sockaddr_in *sa, NETULONG defaultHost) {
     char *colon;
 
     memset((void *)sa,0,sizeof(struct sockaddr_in));
@@ -202,9 +203,9 @@
         char *buf;
         char *hostname;
         u_short port;
-        UINT32 addr;
+        NETULONG 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;
     }
--- old/src/share/transport/socket/sysSocket.h	Mon Jul 21 10:39:29 2008
+++ new/src/share/transport/socket/sysSocket.h	Mon Jul 21 10:39:28 2008
@@ -29,12 +29,13 @@
 #include "sys.h"
 #include "socket_md.h"
 
+/* Network long (32bits) */
 #ifdef _LP64
-typedef unsigned int    UINT32;
-typedef int             INT32;
+typedef unsigned int    NETULONG;
+typedef int             NETLONG;
 #else /* _LP64 */
-typedef unsigned long   UINT32;
-typedef long            INT32;
+typedef unsigned long   NETULONG;
+typedef long            NETLONG;
 #endif /* _LP64 */
 
 #define DBG_POLLIN              1
@@ -44,7 +45,7 @@
 #define DBG_ETIMEOUT            -200
 
 int dbgsysSocketClose(int fd);
-INT32 dbgsysSocketAvailable(int fd, INT32 *pbytes);
+NETLONG dbgsysSocketAvailable(int fd, NETLONG *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 +53,18 @@
               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, NETLONG count);
 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);
+int dbgsysTimeout(int fd, NETLONG 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);
+NETULONG dbgsysInetAddr(const char* cp);
+NETULONG dbgsysHostToNetworkLong(NETULONG hostlong);
 unsigned short dbgsysHostToNetworkShort(unsigned short hostshort);
-UINT32 dbgsysNetworkToHostLong(UINT32 netlong);
+NETULONG dbgsysNetworkToHostLong(NETULONG netlong);
 unsigned short dbgsysNetworkToHostShort(unsigned short netshort);
 int dbgsysGetSocketName(int fd, struct sockaddr *him, int *len);
 int dbgsysConfigureBlocking(int fd, jboolean blocking);
--- old/src/solaris/transport/socket/socket_md.c	Mon Jul 21 10:39:30 2008
+++ new/src/solaris/transport/socket/socket_md.c	Mon Jul 21 10:39:30 2008
@@ -45,7 +45,7 @@
 #include "sysSocket.h"
 
 int
-dbgsysListen(int fd, INT32 count) {
+dbgsysListen(int fd, NETLONG count) {
     return listen(fd, count);
 }
 
@@ -131,13 +131,13 @@
     return bind(fd, name, namelen);
 }
 
-UINT32
+NETULONG
 dbgsysInetAddr(const char* cp) {
-    return (UINT32)inet_addr(cp);
+    return (NETULONG)inet_addr(cp);
 }
 
-UINT32
-dbgsysHostToNetworkLong(UINT32 hostlong) {
+NETULONG
+dbgsysHostToNetworkLong(NETULONG hostlong) {
     return htonl(hostlong);
 }
 
@@ -151,8 +151,8 @@
     return getsockname(fd, name, namelen);
 }
 
-UINT32
-dbgsysNetworkToHostLong(UINT32 netlong) {
+NETULONG
+dbgsysNetworkToHostLong(NETULONG 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;
+        NETLONG onl = (NETLONG)on;
 
         if (setsockopt(fd, tcp_level, TCP_NODELAY,
-                       (char *)&onl, sizeof(INT32)) < 0) {
+                       (char *)&onl, sizeof(NETLONG)) < 0) {
                 return SYS_ERR;
         }
     } else if (cmd == SO_LINGER) {
--- old/src/windows/transport/socket/socket_md.c	Mon Jul 21 10:39:31 2008
+++ new/src/windows/transport/socket/socket_md.c	Mon Jul 21 10:39:31 2008
@@ -120,7 +120,7 @@
  * function pointer table, but our pointer should still be good.
  */
 int
-dbgsysListen(int fd, INT32 count) {
+dbgsysListen(int fd, NETLONG count) {
     return listen(fd, (int)count);
 }
 
@@ -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,10 +229,10 @@
     return closesocket(fd);
 }
 
-INT32
-dbgsysSocketAvailable(int fd, INT32 *pbytes) {
+NETLONG
+dbgsysSocketAvailable(int fd, NETLONG *pbytes) {
     u_long arg = (u_long)*pbytes;
-    return (INT32)ioctlsocket(fd, FIONREAD, &arg);
+    return (NETLONG)ioctlsocket(fd, FIONREAD, &arg);
 }
 
 /* Additions to original follow */
@@ -243,14 +243,14 @@
 }
 
 
-UINT32
+NETULONG
 dbgsysInetAddr(const char* cp) {
-    return (UINT32)inet_addr(cp);
+    return (NETULONG)inet_addr(cp);
 }
 
-UINT32
-dbgsysHostToNetworkLong(UINT32 hostlong) {
-    return (UINT32)htonl((u_long)hostlong);
+NETULONG
+dbgsysHostToNetworkLong(NETULONG hostlong) {
+    return (NETULONG)htonl((u_long)hostlong);
 }
 
 unsigned short
@@ -263,9 +263,9 @@
     return getsockname(fd, name, namelen);
 }
 
-UINT32
-dbgsysNetworkToHostLong(UINT32 netlong) {
-    return (UINT32)ntohl((u_long)netlong);
+NETULONG
+dbgsysNetworkToHostLong(NETULONG netlong) {
+    return (NETULONG)ntohl((u_long)netlong);
 }
 
 /*
                                     
2008-07-21
EVALUATION

http://hg.openjdk.java.net/jdk7/tl/jdk/rev/d01e7cae7b3e
                                     
2008-07-24
EVALUATION

http://hg.openjdk.java.net/jdk6/jdk6/jdk/rev/dd7969318d7a
                                     
2009-12-08



Hardware and Software, Engineered to Work Together