|
Description
|
What's wrong with this function?
int
handleFileSizeFD(jlong fd, jlong *size)
{
DWORD sizeLow = 0;
DWORD sizeHigh = 0;
HANDLE h = (HANDLE)fd;
if (h == INVALID_HANDLE_VALUE) {
return -1;
}
sizeLow = GetFileSize(h, &sizeHigh);
if (sizeLow == ((DWORD)-1)) {
if (GetLastError() != ERROR_SUCCESS) {
return -1;
}
}
return (((jlong)sizeHigh) << 32) | sizeLow;
}
Let's see...
The function tries to compute a 64-bit quantity to return,
but the return type is "int", unlikely to be able to hold 64-bits.
Meanwhile, the "size" argument provides a place where the 64-bit quantity
could be stored, but it is simply ignored.
Finally, the function is completely unused. Good thing, that.
Let's put this code out of its misery.
Posted Date : 2007-11-17 20:11:54.0
|