Use unsigned return values in read()-like Pal fns.

Returning a negative number of bytes makes absolutely no sense, besides
the "-1 and errno" pattern, which is now converted to Result<_, Errno>.
This commit is contained in:
4lDO2
2024-09-27 10:39:26 +02:00
parent 986754e7b3
commit 8b8b00da01
12 changed files with 86 additions and 51 deletions
+3 -1
View File
@@ -986,7 +986,9 @@ pub unsafe extern "C" fn realpath(pathname: *const c_char, resolved: *mut c_char
let len = out.len();
// TODO: better error handling
let read = Sys::fpath(*file, &mut out[..len - 1]).or_minus_one_errno();
let read = Sys::fpath(*file, &mut out[..len - 1])
.map(|read| read as ssize_t)
.or_minus_one_errno();
if read < 0 {
return ptr::null_mut();
}