about summary refs log tree commit diff
path: root/src/libnative
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-02-01 11:24:42 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-02-03 10:39:23 -0800
commitc765a8e7ad314651b92ff860cda0159c79dbec6e (patch)
tree5cb922f942920dc7d6b0f3606e9cd914360b2707 /src/libnative
parentf9a32cdabc1680b89bd7b579dc1e3f8f18c28257 (diff)
downloadrust-c765a8e7ad314651b92ff860cda0159c79dbec6e.tar.gz
rust-c765a8e7ad314651b92ff860cda0159c79dbec6e.zip
Fixing remaining warnings and errors throughout
Diffstat (limited to 'src/libnative')
-rw-r--r--src/libnative/io/file.rs8
-rw-r--r--src/libnative/io/process.rs25
-rw-r--r--src/libnative/io/timer_helper.rs4
-rw-r--r--src/libnative/io/timer_win32.rs12
4 files changed, 25 insertions, 24 deletions
diff --git a/src/libnative/io/file.rs b/src/libnative/io/file.rs
index e6bead60d1b..cc5b0770d4d 100644
--- a/src/libnative/io/file.rs
+++ b/src/libnative/io/file.rs
@@ -561,7 +561,7 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> {
                         }
                         more_files = FindNextFileW(find_handle, wfd_ptr as HANDLE);
                     }
-                    FindClose(find_handle);
+                    assert!(FindClose(find_handle) != 0);
                     free(wfd_ptr as *mut c_void);
                     Ok(paths)
                 } else {
@@ -683,7 +683,9 @@ pub fn readlink(p: &CString) -> IoResult<Path> {
                                   ptr::mut_null())
             })
         };
-        if handle == ptr::mut_null() { return Err(super::last_error()) }
+        if handle as int == libc::INVALID_HANDLE_VALUE as int {
+            return Err(super::last_error())
+        }
         let ret = fill_utf16_buf_and_decode(|buf, sz| {
             unsafe {
                 libc::GetFinalPathNameByHandleW(handle, buf as *u16, sz,
@@ -694,7 +696,7 @@ pub fn readlink(p: &CString) -> IoResult<Path> {
             Some(s) => Ok(Path::new(s)),
             None => Err(super::last_error()),
         };
-        unsafe { libc::CloseHandle(handle) };
+        assert!(unsafe { libc::CloseHandle(handle) } != 0);
         return ret;
 
     }
diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs
index c2522d551b6..2a061c5f9b2 100644
--- a/src/libnative/io/process.rs
+++ b/src/libnative/io/process.rs
@@ -149,9 +149,8 @@ impl rtio::RtioProcess for Process {
         unsafe fn killpid(pid: pid_t, signal: int) -> Result<(), io::IoError> {
             match signal {
                 io::process::PleaseExitSignal | io::process::MustDieSignal => {
-                    libc::funcs::extra::kernel32::TerminateProcess(
-                        cast::transmute(pid), 1);
-                    Ok(())
+                    let ret = libc::TerminateProcess(pid as libc::HANDLE, 1);
+                    super::mkerr_winbool(ret)
                 }
                 _ => Err(io::IoError {
                     kind: io::OtherIoError,
@@ -255,9 +254,9 @@ fn spawn_process_os(prog: &str, args: &[~str],
             })
         });
 
-        CloseHandle(si.hStdInput);
-        CloseHandle(si.hStdOutput);
-        CloseHandle(si.hStdError);
+        assert!(CloseHandle(si.hStdInput) != 0);
+        assert!(CloseHandle(si.hStdOutput) != 0);
+        assert!(CloseHandle(si.hStdError) != 0);
 
         match create_err {
             Some(err) => return Err(err),
@@ -269,7 +268,7 @@ fn spawn_process_os(prog: &str, args: &[~str],
         // able to close it later. We don't close the process handle however
         // because std::we want the process id to stay valid at least until the
         // calling code closes the process handle.
-        CloseHandle(pi.hThread);
+        assert!(CloseHandle(pi.hThread) != 0);
 
         Ok(SpawnProcessResult {
             pid: pi.dwProcessId as pid_t,
@@ -576,9 +575,9 @@ fn with_dirp<T>(d: Option<&Path>, cb: |*libc::c_char| -> T) -> T {
 
 #[cfg(windows)]
 fn free_handle(handle: *()) {
-    unsafe {
-        libc::funcs::extra::kernel32::CloseHandle(cast::transmute(handle));
-    }
+    assert!(unsafe {
+        libc::CloseHandle(cast::transmute(handle)) != 0
+    })
 }
 
 #[cfg(unix)]
@@ -629,15 +628,15 @@ fn waitpid(pid: pid_t) -> p::ProcessExit {
             loop {
                 let mut status = 0;
                 if GetExitCodeProcess(process, &mut status) == FALSE {
-                    CloseHandle(process);
+                    assert!(CloseHandle(process) != 0);
                     fail!("failure in GetExitCodeProcess: {}", os::last_os_error());
                 }
                 if status != STILL_ACTIVE {
-                    CloseHandle(process);
+                    assert!(CloseHandle(process) != 0);
                     return p::ExitStatus(status as int);
                 }
                 if WaitForSingleObject(process, INFINITE) == WAIT_FAILED {
-                    CloseHandle(process);
+                    assert!(CloseHandle(process) != 0);
                     fail!("failure in WaitForSingleObject: {}", os::last_os_error());
                 }
             }
diff --git a/src/libnative/io/timer_helper.rs b/src/libnative/io/timer_helper.rs
index 74759b467d4..7311be46e8b 100644
--- a/src/libnative/io/timer_helper.rs
+++ b/src/libnative/io/timer_helper.rs
@@ -126,11 +126,11 @@ mod imp {
     }
 
     pub fn signal(handle: HANDLE) {
-        unsafe { SetEvent(handle); }
+        assert!(unsafe { SetEvent(handle) != 0 });
     }
 
     pub fn close(handle: HANDLE) {
-        unsafe { CloseHandle(handle); }
+        assert!(unsafe { CloseHandle(handle) != 0 });
     }
 
     extern "system" {
diff --git a/src/libnative/io/timer_win32.rs b/src/libnative/io/timer_win32.rs
index e359d99eedf..6b472d2f46d 100644
--- a/src/libnative/io/timer_win32.rs
+++ b/src/libnative/io/timer_win32.rs
@@ -62,8 +62,8 @@ fn helper(input: libc::HANDLE, messages: Port<Req>) {
                         c.send(());
                         match objs.iter().position(|&o| o == obj) {
                             Some(i) => {
-                                objs.remove(i);
-                                chans.remove(i - 1);
+                                drop(objs.remove(i));
+                                drop(chans.remove(i - 1));
                             }
                             None => {}
                         }
@@ -83,8 +83,8 @@ fn helper(input: libc::HANDLE, messages: Port<Req>) {
                 }
             };
             if remove {
-                objs.remove(idx as uint);
-                chans.remove(idx as uint - 1);
+                drop(objs.remove(idx as uint));
+                drop(chans.remove(idx as uint - 1));
             }
         }
     }
@@ -133,7 +133,7 @@ impl rtio::RtioTimer for Timer {
                                   ptr::mut_null(), 0)
         }, 1);
 
-        unsafe { imp::WaitForSingleObject(self.obj, libc::INFINITE); }
+        let _ = unsafe { imp::WaitForSingleObject(self.obj, libc::INFINITE) };
     }
 
     fn oneshot(&mut self, msecs: u64) -> Port<()> {
@@ -173,7 +173,7 @@ impl rtio::RtioTimer for Timer {
 impl Drop for Timer {
     fn drop(&mut self) {
         self.remove();
-        unsafe { libc::CloseHandle(self.obj); }
+        assert!(unsafe { libc::CloseHandle(self.obj) != 0 });
     }
 }