Cygwin: raw disk I/O: Fix return value in error case
The cast to generate the return value uses a DWORD variable as test and set value. The error case is the constant -1. Given the type of the other half of the conditioal expression, -1 is cast to DWORD as well. On 64 bit, this results in the error case returning a 32 bit -1 value which is equivalent to (ssize_t) 4294967295 rather than (ssize_t) -1. Add a fixing cast. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
5a7e130c31
commit
b834921895
|
@ -619,12 +619,12 @@ fhandler_dev_floppy::raw_write (const void *ptr, size_t len)
|
|||
devbufend = bytes_per_sector;
|
||||
}
|
||||
}
|
||||
return bytes_written;
|
||||
return (ssize_t) bytes_written;
|
||||
}
|
||||
|
||||
/* In O_DIRECT case, just write. */
|
||||
if (write_file (p, len, &bytes_written, &ret))
|
||||
return bytes_written;
|
||||
return (ssize_t) bytes_written;
|
||||
|
||||
err:
|
||||
if (IS_EOM (ret))
|
||||
|
@ -635,7 +635,8 @@ err:
|
|||
}
|
||||
else if (!bytes_written)
|
||||
__seterrno ();
|
||||
return bytes_written ?: -1;
|
||||
/* Cast is required, otherwise the error return value is (DWORD)-1. */
|
||||
return (ssize_t) bytes_written ?: -1;
|
||||
}
|
||||
|
||||
off_t
|
||||
|
|
Loading…
Reference in New Issue