Skip to content

Commit 22224ca

Browse files
committed
Auto merge of #21932 - Jormundir:std-os-errno-type, r=alexcrichton
Changes std::os::errno to return i32, the return type used by the function being delegated to. This is my first contribution, so feel free to give me advice. I'll be happy to correct things.
2 parents 81bce52 + 64d33b1 commit 22224ca

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/libstd/old_io/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl IoError {
338338
/// If `detail` is `true`, the `detail` field of the `IoError`
339339
/// struct is filled with an allocated string describing the error
340340
/// in more detail, retrieved from the operating system.
341-
pub fn from_errno(errno: uint, detail: bool) -> IoError {
341+
pub fn from_errno(errno: i32, detail: bool) -> IoError {
342342
let mut err = sys::decode_error(errno as i32);
343343
if detail && err.kind == OtherIoError {
344344
err.detail = Some(os::error_string(errno).chars()
@@ -354,7 +354,7 @@ impl IoError {
354354
/// operating system) between the call(s) for which errors are
355355
/// being checked and the call of this function.
356356
pub fn last_error() -> IoError {
357-
IoError::from_errno(os::errno() as uint, true)
357+
IoError::from_errno(os::errno(), true)
358358
}
359359
}
360360

src/libstd/os.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,8 @@ pub fn change_dir(p: &Path) -> IoResult<()> {
514514
}
515515

516516
/// Returns the platform-specific value of errno
517-
pub fn errno() -> uint {
518-
sys::os::errno() as uint
517+
pub fn errno() -> i32 {
518+
sys::os::errno() as i32
519519
}
520520

521521
/// Return the string corresponding to an `errno()` value of `errnum`.
@@ -525,15 +525,15 @@ pub fn errno() -> uint {
525525
/// use std::os;
526526
///
527527
/// // Same as println!("{}", last_os_error());
528-
/// println!("{}", os::error_string(os::errno() as uint));
528+
/// println!("{}", os::error_string(os::errno() as i32));
529529
/// ```
530-
pub fn error_string(errnum: uint) -> String {
531-
return sys::os::error_string(errnum as i32);
530+
pub fn error_string(errnum: i32) -> String {
531+
return sys::os::error_string(errnum);
532532
}
533533

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

539539
/// Sets the process exit code
@@ -845,13 +845,13 @@ pub enum MapError {
845845
ErrAlreadyExists,
846846
/// Unrecognized error from `VirtualAlloc`. The inner value is the return
847847
/// value of GetLastError.
848-
ErrVirtualAlloc(uint),
848+
ErrVirtualAlloc(i32),
849849
/// Unrecognized error from `CreateFileMapping`. The inner value is the
850850
/// return value of `GetLastError`.
851-
ErrCreateFileMappingW(uint),
851+
ErrCreateFileMappingW(i32),
852852
/// Unrecognized error from `MapViewOfFile`. The inner value is the return
853853
/// value of `GetLastError`.
854-
ErrMapViewOfFile(uint)
854+
ErrMapViewOfFile(i32)
855855
}
856856

857857
#[stable(feature = "rust1", since = "1.0.0")]

src/libstd/sys/unix/process.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ impl Process {
394394
match unsafe { c::select(max, &mut set, ptr::null_mut(),
395395
ptr::null_mut(), p) } {
396396
// interrupted, retry
397-
-1 if os::errno() == libc::EINTR as uint => continue,
397+
-1 if os::errno() == libc::EINTR as i32 => continue,
398398

399399
// We read something, break out and process
400400
1 | 2 => {}

src/libstd/sys/unix/timer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) {
198198
assert_eq!(fd.read(&mut buf).ok().unwrap(), 1);
199199
}
200200

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

0 commit comments

Comments
 (0)