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