Skip to content

std::os::errno returns platform specific value. fixes #21898 #21932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libstd/old_io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ impl IoError {
/// If `detail` is `true`, the `detail` field of the `IoError`
/// struct is filled with an allocated string describing the error
/// in more detail, retrieved from the operating system.
pub fn from_errno(errno: uint, detail: bool) -> IoError {
pub fn from_errno(errno: i32, detail: bool) -> IoError {
let mut err = sys::decode_error(errno as i32);
if detail && err.kind == OtherIoError {
err.detail = Some(os::error_string(errno).chars()
Expand All @@ -353,7 +353,7 @@ impl IoError {
/// operating system) between the call(s) for which errors are
/// being checked and the call of this function.
pub fn last_error() -> IoError {
IoError::from_errno(os::errno() as uint, true)
IoError::from_errno(os::errno(), true)
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/libstd/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,8 @@ pub fn change_dir(p: &Path) -> IoResult<()> {
}

/// Returns the platform-specific value of errno
pub fn errno() -> uint {
sys::os::errno() as uint
pub fn errno() -> i32 {
sys::os::errno() as i32
}

/// Return the string corresponding to an `errno()` value of `errnum`.
Expand All @@ -524,15 +524,15 @@ pub fn errno() -> uint {
/// use std::os;
///
/// // Same as println!("{}", last_os_error());
/// println!("{}", os::error_string(os::errno() as uint));
/// println!("{}", os::error_string(os::errno() as i32));
/// ```
pub fn error_string(errnum: uint) -> String {
return sys::os::error_string(errnum as i32);
pub fn error_string(errnum: i32) -> String {
return sys::os::error_string(errnum);
}

/// Get a string representing the platform-dependent last error
pub fn last_os_error() -> String {
error_string(errno() as uint)
error_string(errno())
}

/// Sets the process exit code
Expand Down Expand Up @@ -845,13 +845,13 @@ pub enum MapError {
ErrAlreadyExists,
/// Unrecognized error from `VirtualAlloc`. The inner value is the return
/// value of GetLastError.
ErrVirtualAlloc(uint),
ErrVirtualAlloc(i32),
/// Unrecognized error from `CreateFileMapping`. The inner value is the
/// return value of `GetLastError`.
ErrCreateFileMappingW(uint),
ErrCreateFileMappingW(i32),
/// Unrecognized error from `MapViewOfFile`. The inner value is the return
/// value of `GetLastError`.
ErrMapViewOfFile(uint)
ErrMapViewOfFile(i32)
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ impl Process {
match unsafe { c::select(max, &mut set, ptr::null_mut(),
ptr::null_mut(), p) } {
// interrupted, retry
-1 if os::errno() == libc::EINTR as uint => continue,
-1 if os::errno() == libc::EINTR as i32 => continue,

// We read something, break out and process
1 | 2 => {}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/unix/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) {
assert_eq!(fd.read(&mut buf).ok().unwrap(), 1);
}

-1 if os::errno() == libc::EINTR as uint => {}
-1 if os::errno() == libc::EINTR as i32 => {}
n => panic!("helper thread failed in select() with error: {} ({})",
n, os::last_os_error())
}
Expand Down