提交 c2c33eef 编写于 作者: A alanb

7017454: Residual warnings in sun/nio/** and java/io native code (win64)

Reviewed-by: chegar
上级 5f9cb587
...@@ -44,7 +44,7 @@ readSingle(JNIEnv *env, jobject this, jfieldID fid) { ...@@ -44,7 +44,7 @@ readSingle(JNIEnv *env, jobject this, jfieldID fid) {
JNU_ThrowIOException(env, "Stream Closed"); JNU_ThrowIOException(env, "Stream Closed");
return -1; return -1;
} }
nread = IO_Read(fd, &ret, 1); nread = (jint)IO_Read(fd, &ret, 1);
if (nread == 0) { /* EOF */ if (nread == 0) { /* EOF */
return -1; return -1;
} else if (nread == JVM_IO_ERR) { /* error */ } else if (nread == JVM_IO_ERR) { /* error */
...@@ -108,7 +108,7 @@ readBytes(JNIEnv *env, jobject this, jbyteArray bytes, ...@@ -108,7 +108,7 @@ readBytes(JNIEnv *env, jobject this, jbyteArray bytes,
JNU_ThrowIOException(env, "Stream Closed"); JNU_ThrowIOException(env, "Stream Closed");
nread = -1; nread = -1;
} else { } else {
nread = IO_Read(fd, buf, len); nread = (jint)IO_Read(fd, buf, len);
if (nread > 0) { if (nread > 0) {
(*env)->SetByteArrayRegion(env, bytes, off, nread, (jbyte *)buf); (*env)->SetByteArrayRegion(env, bytes, off, nread, (jbyte *)buf);
} else if (nread == JVM_IO_ERR) { } else if (nread == JVM_IO_ERR) {
...@@ -137,9 +137,9 @@ writeSingle(JNIEnv *env, jobject this, jint byte, jboolean append, jfieldID fid) ...@@ -137,9 +137,9 @@ writeSingle(JNIEnv *env, jobject this, jint byte, jboolean append, jfieldID fid)
return; return;
} }
if (append == JNI_TRUE) { if (append == JNI_TRUE) {
n = IO_Append(fd, &c, 1); n = (jint)IO_Append(fd, &c, 1);
} else { } else {
n = IO_Write(fd, &c, 1); n = (jint)IO_Write(fd, &c, 1);
} }
if (n == JVM_IO_ERR) { if (n == JVM_IO_ERR) {
JNU_ThrowIOExceptionWithLastError(env, "Write error"); JNU_ThrowIOExceptionWithLastError(env, "Write error");
...@@ -190,9 +190,9 @@ writeBytes(JNIEnv *env, jobject this, jbyteArray bytes, ...@@ -190,9 +190,9 @@ writeBytes(JNIEnv *env, jobject this, jbyteArray bytes,
break; break;
} }
if (append == JNI_TRUE) { if (append == JNI_TRUE) {
n = IO_Append(fd, buf+off, len); n = (jint)IO_Append(fd, buf+off, len);
} else { } else {
n = IO_Write(fd, buf+off, len); n = (jint)IO_Write(fd, buf+off, len);
} }
if (n == JVM_IO_ERR) { if (n == JVM_IO_ERR) {
JNU_ThrowIOExceptionWithLastError(env, "Write error"); JNU_ThrowIOExceptionWithLastError(env, "Write error");
......
...@@ -220,19 +220,19 @@ Java_java_io_WinNTFileSystem_canonicalize0(JNIEnv *env, jobject this, ...@@ -220,19 +220,19 @@ Java_java_io_WinNTFileSystem_canonicalize0(JNIEnv *env, jobject this,
/*we estimate the max length of memory needed as /*we estimate the max length of memory needed as
"currentDir. length + pathname.length" "currentDir. length + pathname.length"
*/ */
int len = wcslen(path); int len = (int)wcslen(path);
len += currentDirLength(path, len); len += currentDirLength(path, len);
if (len > MAX_PATH_LENGTH - 1) { if (len > MAX_PATH_LENGTH - 1) {
WCHAR *cp = (WCHAR*)malloc(len * sizeof(WCHAR)); WCHAR *cp = (WCHAR*)malloc(len * sizeof(WCHAR));
if (cp != NULL) { if (cp != NULL) {
if (wcanonicalize(path, cp, len) >= 0) { if (wcanonicalize(path, cp, len) >= 0) {
rv = (*env)->NewString(env, cp, wcslen(cp)); rv = (*env)->NewString(env, cp, (jsize)wcslen(cp));
} }
free(cp); free(cp);
} }
} else } else
if (wcanonicalize(path, canonicalPath, MAX_PATH_LENGTH) >= 0) { if (wcanonicalize(path, canonicalPath, MAX_PATH_LENGTH) >= 0) {
rv = (*env)->NewString(env, canonicalPath, wcslen(canonicalPath)); rv = (*env)->NewString(env, canonicalPath, (jsize)wcslen(canonicalPath));
} }
} END_UNICODE_STRING(env, path); } END_UNICODE_STRING(env, path);
if (rv == NULL) { if (rv == NULL) {
...@@ -251,14 +251,14 @@ Java_java_io_WinNTFileSystem_canonicalizeWithPrefix0(JNIEnv *env, jobject this, ...@@ -251,14 +251,14 @@ Java_java_io_WinNTFileSystem_canonicalizeWithPrefix0(JNIEnv *env, jobject this,
WCHAR canonicalPath[MAX_PATH_LENGTH]; WCHAR canonicalPath[MAX_PATH_LENGTH];
WITH_UNICODE_STRING(env, canonicalPrefixString, canonicalPrefix) { WITH_UNICODE_STRING(env, canonicalPrefixString, canonicalPrefix) {
WITH_UNICODE_STRING(env, pathWithCanonicalPrefixString, pathWithCanonicalPrefix) { WITH_UNICODE_STRING(env, pathWithCanonicalPrefixString, pathWithCanonicalPrefix) {
int len = wcslen(canonicalPrefix) + MAX_PATH; int len = (int)wcslen(canonicalPrefix) + MAX_PATH;
if (len > MAX_PATH_LENGTH) { if (len > MAX_PATH_LENGTH) {
WCHAR *cp = (WCHAR*)malloc(len * sizeof(WCHAR)); WCHAR *cp = (WCHAR*)malloc(len * sizeof(WCHAR));
if (cp != NULL) { if (cp != NULL) {
if (wcanonicalizeWithPrefix(canonicalPrefix, if (wcanonicalizeWithPrefix(canonicalPrefix,
pathWithCanonicalPrefix, pathWithCanonicalPrefix,
cp, len) >= 0) { cp, len) >= 0) {
rv = (*env)->NewString(env, cp, wcslen(cp)); rv = (*env)->NewString(env, cp, (jsize)wcslen(cp));
} }
free(cp); free(cp);
} }
...@@ -266,7 +266,7 @@ Java_java_io_WinNTFileSystem_canonicalizeWithPrefix0(JNIEnv *env, jobject this, ...@@ -266,7 +266,7 @@ Java_java_io_WinNTFileSystem_canonicalizeWithPrefix0(JNIEnv *env, jobject this,
if (wcanonicalizeWithPrefix(canonicalPrefix, if (wcanonicalizeWithPrefix(canonicalPrefix,
pathWithCanonicalPrefix, pathWithCanonicalPrefix,
canonicalPath, MAX_PATH_LENGTH) >= 0) { canonicalPath, MAX_PATH_LENGTH) >= 0) {
rv = (*env)->NewString(env, canonicalPath, wcslen(canonicalPath)); rv = (*env)->NewString(env, canonicalPath, (jsize)wcslen(canonicalPath));
} }
} END_UNICODE_STRING(env, pathWithCanonicalPrefix); } END_UNICODE_STRING(env, pathWithCanonicalPrefix);
} END_UNICODE_STRING(env, canonicalPrefix); } END_UNICODE_STRING(env, canonicalPrefix);
...@@ -358,7 +358,7 @@ Java_java_io_WinNTFileSystem_getBooleanAttributes(JNIEnv *env, jobject this, ...@@ -358,7 +358,7 @@ Java_java_io_WinNTFileSystem_getBooleanAttributes(JNIEnv *env, jobject this,
} else { /* pagefile.sys is a special case */ } else { /* pagefile.sys is a special case */
if (GetLastError() == ERROR_SHARING_VIOLATION) { if (GetLastError() == ERROR_SHARING_VIOLATION) {
rv = java_io_FileSystem_BA_EXISTS; rv = java_io_FileSystem_BA_EXISTS;
if ((pathlen = wcslen(pathbuf)) >= SPECIALFILE_NAMELEN && if ((pathlen = (jint)wcslen(pathbuf)) >= SPECIALFILE_NAMELEN &&
(_wcsicmp(pathbuf + pathlen - SPECIALFILE_NAMELEN, (_wcsicmp(pathbuf + pathlen - SPECIALFILE_NAMELEN,
L"pagefile.sys") == 0) || L"pagefile.sys") == 0) ||
(_wcsicmp(pathbuf + pathlen - SPECIALFILE_NAMELEN, (_wcsicmp(pathbuf + pathlen - SPECIALFILE_NAMELEN,
...@@ -625,7 +625,7 @@ Java_java_io_WinNTFileSystem_list(JNIEnv *env, jobject this, jobject file) ...@@ -625,7 +625,7 @@ Java_java_io_WinNTFileSystem_list(JNIEnv *env, jobject this, jobject file)
} }
/* Remove trailing space chars from directory name */ /* Remove trailing space chars from directory name */
len = wcslen(search_path); len = (int)wcslen(search_path);
while (search_path[len-1] == ' ') { while (search_path[len-1] == ' ') {
len--; len--;
} }
...@@ -668,7 +668,7 @@ Java_java_io_WinNTFileSystem_list(JNIEnv *env, jobject this, jobject file) ...@@ -668,7 +668,7 @@ Java_java_io_WinNTFileSystem_list(JNIEnv *env, jobject this, jobject file)
|| !wcscmp(find_data.cFileName, L"..")) || !wcscmp(find_data.cFileName, L".."))
continue; continue;
name = (*env)->NewString(env, find_data.cFileName, name = (*env)->NewString(env, find_data.cFileName,
wcslen(find_data.cFileName)); (jsize)wcslen(find_data.cFileName));
if (name == NULL) if (name == NULL)
return NULL; // error; return NULL; // error;
if (len == maxlen) { if (len == maxlen) {
...@@ -819,7 +819,7 @@ Java_java_io_WinNTFileSystem_getDriveDirectory(JNIEnv *env, jobject this, ...@@ -819,7 +819,7 @@ Java_java_io_WinNTFileSystem_getDriveDirectory(JNIEnv *env, jobject this,
jchar *pf = p; jchar *pf = p;
if (p == NULL) return NULL; if (p == NULL) return NULL;
if (iswalpha(*p) && (p[1] == L':')) p += 2; if (iswalpha(*p) && (p[1] == L':')) p += 2;
ret = (*env)->NewString(env, p, wcslen(p)); ret = (*env)->NewString(env, p, (jsize)wcslen(p));
free (pf); free (pf);
return ret; return ret;
} }
......
...@@ -479,7 +479,7 @@ wcanonicalize(WCHAR *orig_path, WCHAR *result, int size) ...@@ -479,7 +479,7 @@ wcanonicalize(WCHAR *orig_path, WCHAR *result, int size)
assert(*src == L'\\'); /* Invariant */ assert(*src == L'\\'); /* Invariant */
*p = L'\0'; /* Temporarily clear separator */ *p = L'\0'; /* Temporarily clear separator */
if ((pathlen = wcslen(path)) > MAX_PATH - 1) { if ((pathlen = (int)wcslen(path)) > MAX_PATH - 1) {
pathbuf = getPrefixed(path, pathlen); pathbuf = getPrefixed(path, pathlen);
h = FindFirstFileW(pathbuf, &fd); /* Look up prefix */ h = FindFirstFileW(pathbuf, &fd); /* Look up prefix */
free(pathbuf); free(pathbuf);
...@@ -538,7 +538,7 @@ wcanonicalizeWithPrefix(WCHAR *canonicalPrefix, WCHAR *pathWithCanonicalPrefix, ...@@ -538,7 +538,7 @@ wcanonicalizeWithPrefix(WCHAR *canonicalPrefix, WCHAR *pathWithCanonicalPrefix,
dend = dst + size; /* Don't go to or past here */ dend = dst + size; /* Don't go to or past here */
if ((pathlen=wcslen(pathWithCanonicalPrefix)) > MAX_PATH - 1) { if ((pathlen=(int)wcslen(pathWithCanonicalPrefix)) > MAX_PATH - 1) {
pathbuf = getPrefixed(pathWithCanonicalPrefix, pathlen); pathbuf = getPrefixed(pathWithCanonicalPrefix, pathlen);
h = FindFirstFileW(pathbuf, &fd); /* Look up prefix */ h = FindFirstFileW(pathbuf, &fd); /* Look up prefix */
free(pathbuf); free(pathbuf);
......
...@@ -104,7 +104,7 @@ currentDirLength(const WCHAR* ps, int pathlen) { ...@@ -104,7 +104,7 @@ currentDirLength(const WCHAR* ps, int pathlen) {
else return 0; /* invalid drive name. */ else return 0; /* invalid drive name. */
dir = currentDir(di); dir = currentDir(di);
if (dir != NULL){ if (dir != NULL){
dirlen = wcslen(dir); dirlen = (int)wcslen(dir);
free(dir); free(dir);
} }
return dirlen; return dirlen;
...@@ -115,7 +115,7 @@ currentDirLength(const WCHAR* ps, int pathlen) { ...@@ -115,7 +115,7 @@ currentDirLength(const WCHAR* ps, int pathlen) {
int dirlen = -1; int dirlen = -1;
dir = _wgetcwd(NULL, MAX_PATH); dir = _wgetcwd(NULL, MAX_PATH);
if (dir != NULL) { if (dir != NULL) {
curDirLenCached = wcslen(dir); curDirLenCached = (int)wcslen(dir);
free(dir); free(dir);
} }
} }
...@@ -165,7 +165,7 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) { ...@@ -165,7 +165,7 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) {
int max_path = 248; /* CreateDirectoryW() has the limit of 248 */ int max_path = 248; /* CreateDirectoryW() has the limit of 248 */
WITH_UNICODE_STRING(env, path, ps) { WITH_UNICODE_STRING(env, path, ps) {
pathlen = wcslen(ps); pathlen = (int)wcslen(ps);
if (pathlen != 0) { if (pathlen != 0) {
if (pathlen > 2 && if (pathlen > 2 &&
(ps[0] == L'\\' && ps[1] == L'\\' || //UNC (ps[0] == L'\\' && ps[1] == L'\\' || //UNC
......
...@@ -72,9 +72,10 @@ JNIEXPORT jlong JNICALL ...@@ -72,9 +72,10 @@ JNIEXPORT jlong JNICALL
Java_sun_nio_ch_Iocp_createIoCompletionPort(JNIEnv* env, jclass this, Java_sun_nio_ch_Iocp_createIoCompletionPort(JNIEnv* env, jclass this,
jlong handle, jlong existingPort, jint completionKey, jint concurrency) jlong handle, jlong existingPort, jint completionKey, jint concurrency)
{ {
ULONG_PTR ck = completionKey;
HANDLE port = CreateIoCompletionPort((HANDLE)jlong_to_ptr(handle), HANDLE port = CreateIoCompletionPort((HANDLE)jlong_to_ptr(handle),
(HANDLE)jlong_to_ptr(existingPort), (HANDLE)jlong_to_ptr(existingPort),
(DWORD)completionKey, ck,
(DWORD)concurrency); (DWORD)concurrency);
if (port == NULL) { if (port == NULL) {
JNU_ThrowIOExceptionWithLastError(env, "CreateIoCompletionPort failed"); JNU_ThrowIOExceptionWithLastError(env, "CreateIoCompletionPort failed");
...@@ -96,7 +97,7 @@ Java_sun_nio_ch_Iocp_getQueuedCompletionStatus(JNIEnv* env, jclass this, ...@@ -96,7 +97,7 @@ Java_sun_nio_ch_Iocp_getQueuedCompletionStatus(JNIEnv* env, jclass this,
jlong completionPort, jobject obj) jlong completionPort, jobject obj)
{ {
DWORD bytesTransferred; DWORD bytesTransferred;
DWORD completionKey; ULONG_PTR completionKey;
OVERLAPPED *lpOverlapped; OVERLAPPED *lpOverlapped;
BOOL res; BOOL res;
......
...@@ -51,7 +51,7 @@ Java_sun_nio_fs_RegistryFileTypeDetector_queryStringValue(JNIEnv* env, jclass th ...@@ -51,7 +51,7 @@ Java_sun_nio_fs_RegistryFileTypeDetector_queryStringValue(JNIEnv* env, jclass th
res = RegQueryValueExW(hKey, lpValueName, NULL, &type, (LPBYTE)&data, &size); res = RegQueryValueExW(hKey, lpValueName, NULL, &type, (LPBYTE)&data, &size);
if (res == ERROR_SUCCESS) { if (res == ERROR_SUCCESS) {
if (type == REG_SZ) { if (type == REG_SZ) {
jsize len = wcslen((WCHAR*)data); jsize len = (jsize)wcslen((WCHAR*)data);
result = (*env)->NewString(env, (const jchar*)&data, len); result = (*env)->NewString(env, (const jchar*)&data, len);
} }
} }
......
...@@ -368,7 +368,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_FindFirstFile0(JNIEnv* env, jclass this, ...@@ -368,7 +368,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_FindFirstFile0(JNIEnv* env, jclass this,
HANDLE handle = FindFirstFileW(lpFileName, &data); HANDLE handle = FindFirstFileW(lpFileName, &data);
if (handle != INVALID_HANDLE_VALUE) { if (handle != INVALID_HANDLE_VALUE) {
jstring name = (*env)->NewString(env, data.cFileName, wcslen(data.cFileName)); jstring name = (*env)->NewString(env, data.cFileName, (jsize)wcslen(data.cFileName));
if (name == NULL) if (name == NULL)
return; return;
(*env)->SetLongField(env, obj, findFirst_handle, ptr_to_jlong(handle)); (*env)->SetLongField(env, obj, findFirst_handle, ptr_to_jlong(handle));
...@@ -401,7 +401,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_FindNextFile(JNIEnv* env, jclass this, ...@@ -401,7 +401,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_FindNextFile(JNIEnv* env, jclass this,
WIN32_FIND_DATAW* data = (WIN32_FIND_DATAW*)jlong_to_ptr(dataAddress); WIN32_FIND_DATAW* data = (WIN32_FIND_DATAW*)jlong_to_ptr(dataAddress);
if (FindNextFileW(h, data) != 0) { if (FindNextFileW(h, data) != 0) {
return (*env)->NewString(env, data->cFileName, wcslen(data->cFileName)); return (*env)->NewString(env, data->cFileName, (jsize)wcslen(data->cFileName));
} else { } else {
if (GetLastError() != ERROR_NO_MORE_FILES) if (GetLastError() != ERROR_NO_MORE_FILES)
throwWindowsException(env, GetLastError()); throwWindowsException(env, GetLastError());
...@@ -424,7 +424,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_FindFirstStream0(JNIEnv* env, jclass thi ...@@ -424,7 +424,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_FindFirstStream0(JNIEnv* env, jclass thi
handle = (*FindFirstStream_func)(lpFileName, FindStreamInfoStandard, &data, 0); handle = (*FindFirstStream_func)(lpFileName, FindStreamInfoStandard, &data, 0);
if (handle != INVALID_HANDLE_VALUE) { if (handle != INVALID_HANDLE_VALUE) {
jstring name = (*env)->NewString(env, data.cStreamName, wcslen(data.cStreamName)); jstring name = (*env)->NewString(env, data.cStreamName, (jsize)wcslen(data.cStreamName));
if (name == NULL) if (name == NULL)
return; return;
(*env)->SetLongField(env, obj, findStream_handle, ptr_to_jlong(handle)); (*env)->SetLongField(env, obj, findStream_handle, ptr_to_jlong(handle));
...@@ -452,7 +452,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_FindNextStream(JNIEnv* env, jclass this, ...@@ -452,7 +452,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_FindNextStream(JNIEnv* env, jclass this,
} }
if ((*FindNextStream_func)(h, &data) != 0) { if ((*FindNextStream_func)(h, &data) != 0) {
return (*env)->NewString(env, data.cStreamName, wcslen(data.cStreamName)); return (*env)->NewString(env, data.cStreamName, (jsize)wcslen(data.cStreamName));
} else { } else {
if (GetLastError() != ERROR_HANDLE_EOF) if (GetLastError() != ERROR_HANDLE_EOF)
throwWindowsException(env, GetLastError()); throwWindowsException(env, GetLastError());
...@@ -1224,9 +1224,10 @@ JNIEXPORT jlong JNICALL ...@@ -1224,9 +1224,10 @@ JNIEXPORT jlong JNICALL
Java_sun_nio_fs_WindowsNativeDispatcher_CreateIoCompletionPort(JNIEnv* env, jclass this, Java_sun_nio_fs_WindowsNativeDispatcher_CreateIoCompletionPort(JNIEnv* env, jclass this,
jlong fileHandle, jlong existingPort, jint completionKey) jlong fileHandle, jlong existingPort, jint completionKey)
{ {
ULONG_PTR ck = completionKey;
HANDLE port = CreateIoCompletionPort((HANDLE)jlong_to_ptr(fileHandle), HANDLE port = CreateIoCompletionPort((HANDLE)jlong_to_ptr(fileHandle),
(HANDLE)jlong_to_ptr(existingPort), (HANDLE)jlong_to_ptr(existingPort),
(DWORD)completionKey, ck,
0); 0);
if (port == NULL) { if (port == NULL) {
throwWindowsException(env, GetLastError()); throwWindowsException(env, GetLastError());
...@@ -1239,7 +1240,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_GetQueuedCompletionStatus0(JNIEnv* env, ...@@ -1239,7 +1240,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_GetQueuedCompletionStatus0(JNIEnv* env,
jlong completionPort, jobject obj) jlong completionPort, jobject obj)
{ {
DWORD bytesTransferred; DWORD bytesTransferred;
DWORD completionKey; ULONG_PTR completionKey;
OVERLAPPED *lpOverlapped; OVERLAPPED *lpOverlapped;
BOOL res; BOOL res;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册