windows: Fix INVALID_HANDLE_VALUE
Made INVALID_HANDLE_VALUE actually a HANDLE. Removed all useless casts during INVALID_HANDLE_VALUE comparisons. Signed-off-by: Peter Atashian <retep998@gmail.com>
This commit is contained in:
parent
feb219d23f
commit
24ebbb4420
5 changed files with 17 additions and 18 deletions
|
@ -1142,8 +1142,7 @@ pub mod types {
|
||||||
pub mod os {
|
pub mod os {
|
||||||
pub mod common {
|
pub mod common {
|
||||||
pub mod posix01 {
|
pub mod posix01 {
|
||||||
use types::os::arch::c95::{c_short, time_t,
|
use types::os::arch::c95::{c_short, time_t, c_long};
|
||||||
c_long};
|
|
||||||
use types::os::arch::extra::{int64, time64_t};
|
use types::os::arch::extra::{int64, time64_t};
|
||||||
use types::os::arch::posix88::{dev_t, ino_t};
|
use types::os::arch::posix88::{dev_t, ino_t};
|
||||||
|
|
||||||
|
@ -1947,7 +1946,7 @@ pub mod consts {
|
||||||
}
|
}
|
||||||
pub mod extra {
|
pub mod extra {
|
||||||
use types::os::arch::c95::c_int;
|
use types::os::arch::c95::c_int;
|
||||||
use types::os::arch::extra::{WORD, DWORD, BOOL};
|
use types::os::arch::extra::{WORD, DWORD, BOOL, HANDLE};
|
||||||
|
|
||||||
pub static TRUE : BOOL = 1;
|
pub static TRUE : BOOL = 1;
|
||||||
pub static FALSE : BOOL = 0;
|
pub static FALSE : BOOL = 0;
|
||||||
|
@ -1976,7 +1975,7 @@ pub mod consts {
|
||||||
pub static ERROR_IO_PENDING: c_int = 997;
|
pub static ERROR_IO_PENDING: c_int = 997;
|
||||||
pub static ERROR_FILE_INVALID : c_int = 1006;
|
pub static ERROR_FILE_INVALID : c_int = 1006;
|
||||||
pub static ERROR_NOT_FOUND: c_int = 1168;
|
pub static ERROR_NOT_FOUND: c_int = 1168;
|
||||||
pub static INVALID_HANDLE_VALUE : c_int = -1;
|
pub static INVALID_HANDLE_VALUE: HANDLE = -1 as HANDLE;
|
||||||
|
|
||||||
pub static DELETE : DWORD = 0x00010000;
|
pub static DELETE : DWORD = 0x00010000;
|
||||||
pub static READ_CONTROL : DWORD = 0x00020000;
|
pub static READ_CONTROL : DWORD = 0x00020000;
|
||||||
|
|
|
@ -320,7 +320,7 @@ pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess)
|
||||||
dwFlagsAndAttributes,
|
dwFlagsAndAttributes,
|
||||||
ptr::mut_null())
|
ptr::mut_null())
|
||||||
};
|
};
|
||||||
if handle == libc::INVALID_HANDLE_VALUE as libc::HANDLE {
|
if handle == libc::INVALID_HANDLE_VALUE {
|
||||||
Err(super::last_error())
|
Err(super::last_error())
|
||||||
} else {
|
} else {
|
||||||
let fd = unsafe {
|
let fd = unsafe {
|
||||||
|
@ -368,7 +368,7 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
|
||||||
let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint);
|
let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint);
|
||||||
let find_handle = libc::FindFirstFileW(path.as_ptr(),
|
let find_handle = libc::FindFirstFileW(path.as_ptr(),
|
||||||
wfd_ptr as libc::HANDLE);
|
wfd_ptr as libc::HANDLE);
|
||||||
if find_handle as libc::c_int != libc::INVALID_HANDLE_VALUE {
|
if find_handle != libc::INVALID_HANDLE_VALUE {
|
||||||
let mut paths = vec!();
|
let mut paths = vec!();
|
||||||
let mut more_files = 1 as libc::c_int;
|
let mut more_files = 1 as libc::c_int;
|
||||||
while more_files != 0 {
|
while more_files != 0 {
|
||||||
|
@ -440,7 +440,7 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
|
||||||
libc::FILE_ATTRIBUTE_NORMAL,
|
libc::FILE_ATTRIBUTE_NORMAL,
|
||||||
ptr::mut_null())
|
ptr::mut_null())
|
||||||
};
|
};
|
||||||
if handle as int == libc::INVALID_HANDLE_VALUE as int {
|
if handle == libc::INVALID_HANDLE_VALUE {
|
||||||
return Err(super::last_error())
|
return Err(super::last_error())
|
||||||
}
|
}
|
||||||
// Specify (sz - 1) because the documentation states that it's the size
|
// Specify (sz - 1) because the documentation states that it's the size
|
||||||
|
|
|
@ -223,7 +223,7 @@ impl UnixStream {
|
||||||
libc::FILE_FLAG_OVERLAPPED,
|
libc::FILE_FLAG_OVERLAPPED,
|
||||||
ptr::mut_null())
|
ptr::mut_null())
|
||||||
};
|
};
|
||||||
if result != libc::INVALID_HANDLE_VALUE as libc::HANDLE {
|
if result != libc::INVALID_HANDLE_VALUE {
|
||||||
return Some(result)
|
return Some(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ impl UnixStream {
|
||||||
libc::FILE_FLAG_OVERLAPPED,
|
libc::FILE_FLAG_OVERLAPPED,
|
||||||
ptr::mut_null())
|
ptr::mut_null())
|
||||||
};
|
};
|
||||||
if result != libc::INVALID_HANDLE_VALUE as libc::HANDLE {
|
if result != libc::INVALID_HANDLE_VALUE {
|
||||||
return Some(result)
|
return Some(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ impl UnixStream {
|
||||||
libc::FILE_FLAG_OVERLAPPED,
|
libc::FILE_FLAG_OVERLAPPED,
|
||||||
ptr::mut_null())
|
ptr::mut_null())
|
||||||
};
|
};
|
||||||
if result != libc::INVALID_HANDLE_VALUE as libc::HANDLE {
|
if result != libc::INVALID_HANDLE_VALUE {
|
||||||
return Some(result)
|
return Some(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -565,7 +565,7 @@ impl UnixListener {
|
||||||
// and such.
|
// and such.
|
||||||
let addr_v = try!(to_utf16(addr));
|
let addr_v = try!(to_utf16(addr));
|
||||||
let ret = unsafe { pipe(addr_v.as_ptr(), true) };
|
let ret = unsafe { pipe(addr_v.as_ptr(), true) };
|
||||||
if ret == libc::INVALID_HANDLE_VALUE as libc::HANDLE {
|
if ret == libc::INVALID_HANDLE_VALUE {
|
||||||
Err(super::last_error())
|
Err(super::last_error())
|
||||||
} else {
|
} else {
|
||||||
Ok(UnixListener { handle: ret, name: addr.clone() })
|
Ok(UnixListener { handle: ret, name: addr.clone() })
|
||||||
|
@ -680,7 +680,7 @@ impl UnixAcceptor {
|
||||||
// create a second server pipe. If this fails, we disconnect the
|
// create a second server pipe. If this fails, we disconnect the
|
||||||
// connected client and return an error (see comments above).
|
// connected client and return an error (see comments above).
|
||||||
let new_handle = unsafe { pipe(name.as_ptr(), false) };
|
let new_handle = unsafe { pipe(name.as_ptr(), false) };
|
||||||
if new_handle == libc::INVALID_HANDLE_VALUE as libc::HANDLE {
|
if new_handle == libc::INVALID_HANDLE_VALUE {
|
||||||
let ret = Err(super::last_error());
|
let ret = Err(super::last_error());
|
||||||
// If our disconnection fails, then there's not really a whole lot
|
// If our disconnection fails, then there's not really a whole lot
|
||||||
// that we can do, so fail the task.
|
// that we can do, so fail the task.
|
||||||
|
|
|
@ -359,13 +359,13 @@ fn spawn_process_os(cfg: ProcessConfig,
|
||||||
libc::OPEN_EXISTING,
|
libc::OPEN_EXISTING,
|
||||||
0,
|
0,
|
||||||
ptr::mut_null());
|
ptr::mut_null());
|
||||||
if *slot == INVALID_HANDLE_VALUE as libc::HANDLE {
|
if *slot == INVALID_HANDLE_VALUE {
|
||||||
return Err(super::last_error())
|
return Err(super::last_error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(ref fd) => {
|
Some(ref fd) => {
|
||||||
let orig = get_osfhandle(fd.fd()) as HANDLE;
|
let orig = get_osfhandle(fd.fd()) as HANDLE;
|
||||||
if orig == INVALID_HANDLE_VALUE as HANDLE {
|
if orig == INVALID_HANDLE_VALUE {
|
||||||
return Err(super::last_error())
|
return Err(super::last_error())
|
||||||
}
|
}
|
||||||
if DuplicateHandle(cur_proc, orig, cur_proc, slot,
|
if DuplicateHandle(cur_proc, orig, cur_proc, slot,
|
||||||
|
@ -450,9 +450,9 @@ fn zeroed_startupinfo() -> libc::types::os::arch::extra::STARTUPINFO {
|
||||||
wShowWindow: 0,
|
wShowWindow: 0,
|
||||||
cbReserved2: 0,
|
cbReserved2: 0,
|
||||||
lpReserved2: ptr::mut_null(),
|
lpReserved2: ptr::mut_null(),
|
||||||
hStdInput: libc::INVALID_HANDLE_VALUE as libc::HANDLE,
|
hStdInput: libc::INVALID_HANDLE_VALUE,
|
||||||
hStdOutput: libc::INVALID_HANDLE_VALUE as libc::HANDLE,
|
hStdOutput: libc::INVALID_HANDLE_VALUE,
|
||||||
hStdError: libc::INVALID_HANDLE_VALUE as libc::HANDLE,
|
hStdError: libc::INVALID_HANDLE_VALUE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ mod imp {
|
||||||
libc::FILE_ATTRIBUTE_NORMAL,
|
libc::FILE_ATTRIBUTE_NORMAL,
|
||||||
ptr::mut_null())
|
ptr::mut_null())
|
||||||
};
|
};
|
||||||
if handle as uint == libc::INVALID_HANDLE_VALUE as uint {
|
if handle == libc::INVALID_HANDLE_VALUE {
|
||||||
fail!("create file error: {}", os::last_os_error());
|
fail!("create file error: {}", os::last_os_error());
|
||||||
}
|
}
|
||||||
let mut overlapped: libc::OVERLAPPED = unsafe { mem::zeroed() };
|
let mut overlapped: libc::OVERLAPPED = unsafe { mem::zeroed() };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue