A method with return type size_t returns negative value

Jing LV lvjing at linux.vnet.ibm.com
Tue Apr 26 08:24:05 UTC 2011


Hello,

      Thanks for raising the defect. I see there is no patch now, so I 
create one (as the defect mentioned jint may be good, I use jint here).
      I have no Sun Online Account Id, would someone take a look?

diff --git a/src/windows/native/java/io/io_util_md.c 
b/src/windows/native/java/io/io_util_md.c
index 345f955..50bc988 100644
--- a/src/windows/native/java/io/io_util_md.c
+++ b/src/windows/native/java/io/io_util_md.c
@@ -478,7 +478,7 @@ handleSetLength(jlong fd, jlong length) {
  }

  JNIEXPORT
-size_t
+jint
  handleRead(jlong fd, void *buf, jint len)
  {
      DWORD read = 0;
@@ -502,7 +502,7 @@ handleRead(jlong fd, void *buf, jint len)
      return 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);
  }


于 2011-3-24 20:34, Alan Bateman 写道:
> Jing LV wrote:
>> :
>> Thanks Alan. Would you please tell me the bug number?
> The bug now tracking this is:
>
> 7030624: size_t usages in src/windows/native/java/io/io_util_md.c need 
> to be re-visited
>
> -Alan.
>


-- 
Best Regards,
Jimmy, Jing LV





More information about the core-libs-dev mailing list