提交 3e7e23be 编写于 作者: A alanb

7030624: size_t usages in src/windows/native/java/io/io_util_md.c need to be re-visited

Reviewed-by: lancea, chegar
上级 039d858a
......@@ -44,7 +44,7 @@ readSingle(JNIEnv *env, jobject this, jfieldID fid) {
JNU_ThrowIOException(env, "Stream Closed");
return -1;
}
nread = (jint)IO_Read(fd, &ret, 1);
nread = 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 = (jint)IO_Read(fd, buf, len);
nread = 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 = (jint)IO_Append(fd, &c, 1);
n = IO_Append(fd, &c, 1);
} else {
n = (jint)IO_Write(fd, &c, 1);
n = 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 = (jint)IO_Append(fd, buf+off, len);
n = IO_Append(fd, buf+off, len);
} else {
n = (jint)IO_Write(fd, buf+off, len);
n = IO_Write(fd, buf+off, len);
}
if (n == JVM_IO_ERR) {
JNU_ThrowIOExceptionWithLastError(env, "Write error");
......
......@@ -478,7 +478,7 @@ handleSetLength(jlong fd, jlong length) {
}
JNIEXPORT
size_t
jint
handleRead(jlong fd, void *buf, jint len)
{
DWORD read = 0;
......@@ -499,10 +499,10 @@ handleRead(jlong fd, void *buf, jint len)
}
return -1;
}
return read;
return (jint)read;
}
static size_t writeInternal(jlong fd, const void *buf, jint len, jboolean append)
static jint writeInternal(jlong fd, const void *buf, jint len, jboolean append)
{
BOOL result = 0;
DWORD written = 0;
......@@ -527,16 +527,16 @@ static size_t writeInternal(jlong fd, const void *buf, jint len, jboolean append
if ((h == INVALID_HANDLE_VALUE) || (result == 0)) {
return -1;
}
return (size_t)written;
return (jint)written;
}
JNIEXPORT
size_t handleWrite(jlong fd, const void *buf, jint len) {
jint handleWrite(jlong fd, const void *buf, jint len) {
return writeInternal(fd, buf, len, JNI_FALSE);
}
JNIEXPORT
size_t handleAppend(jlong fd, const void *buf, jint len) {
jint handleAppend(jlong fd, const void *buf, jint len) {
return writeInternal(fd, buf, len, JNI_TRUE);
}
......
......@@ -39,9 +39,9 @@ void fileOpen(JNIEnv *env, jobject this, jstring path, jfieldID fid, int flags);
int handleAvailable(jlong fd, jlong *pbytes);
JNIEXPORT int handleSync(jlong fd);
int handleSetLength(jlong fd, jlong length);
JNIEXPORT size_t handleRead(jlong fd, void *buf, jint len);
JNIEXPORT size_t handleWrite(jlong fd, const void *buf, jint len);
JNIEXPORT size_t handleAppend(jlong fd, const void *buf, jint len);
JNIEXPORT jint handleRead(jlong fd, void *buf, jint len);
JNIEXPORT jint handleWrite(jlong fd, const void *buf, jint len);
JNIEXPORT jint handleAppend(jlong fd, const void *buf, jint len);
jint handleClose(JNIEnv *env, jobject this, jfieldID fid);
jlong handleLseek(jlong fd, jlong offset, jint whence);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册