Skip to content

Commit

Permalink
Fix strerror_r error test
Browse files Browse the repository at this point in the history
`man 3 strerror_r` says:

The XSI-compliant strerror_r() function returns 0 on success. On
error, a (positive) error number is returned (since glibc 2.13), or -1
is returned and errno is set to indicate the error (glibc versions
before 2.13).
  • Loading branch information
Ralith committed Nov 14, 2023
1 parent dfd2144 commit 6868bc6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ where
{
let mut buf = [0u8; 1024];
let c_str = unsafe {
if strerror_r(err.0, buf.as_mut_ptr() as *mut _, buf.len() as size_t) < 0 {
if strerror_r(err.0, buf.as_mut_ptr() as *mut _, buf.len() as size_t) != 0 {
let fm_err = errno();
if fm_err != Errno(libc::ERANGE) {
return callback(Err(fm_err));
Expand Down

0 comments on commit 6868bc6

Please sign in to comment.