about summary refs log tree commit diff
path: root/src/libnative/io
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-01-30 14:28:28 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-02-03 09:32:35 -0800
commitae581a010363b26ef6bae60145ebd17343a343b0 (patch)
treea5fb5e0ddfb26e90129f9ca91ecbc21e4505e142 /src/libnative/io
parent41cde566bb81bdd5f9ffdefadc7c8256c65624dc (diff)
downloadrust-ae581a010363b26ef6bae60145ebd17343a343b0.tar.gz
rust-ae581a010363b26ef6bae60145ebd17343a343b0.zip
native: Require all results are used and fix fallout
Diffstat (limited to 'src/libnative/io')
-rw-r--r--src/libnative/io/file.rs10
-rw-r--r--src/libnative/io/net.rs4
-rw-r--r--src/libnative/io/process.rs20
-rw-r--r--src/libnative/io/timer_other.rs5
4 files changed, 20 insertions, 19 deletions
diff --git a/src/libnative/io/file.rs b/src/libnative/io/file.rs
index 72379275643..e6bead60d1b 100644
--- a/src/libnative/io/file.rs
+++ b/src/libnative/io/file.rs
@@ -422,7 +422,7 @@ impl rtio::RtioFileStream for CFile {
 
 impl Drop for CFile {
     fn drop(&mut self) {
-        unsafe { libc::fclose(self.file); }
+        unsafe { let _ = libc::fclose(self.file); }
     }
 }
 
@@ -512,7 +512,7 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> {
                     paths.push(Path::new(cstr));
                     entry_ptr = readdir(dir_ptr);
                 }
-                closedir(dir_ptr);
+                assert_eq!(closedir(dir_ptr), 0);
                 Ok(paths)
             } else {
                 Err(super::last_error())
@@ -932,7 +932,7 @@ mod tests {
             let mut reader = FileDesc::new(input, true);
             let mut writer = FileDesc::new(out, true);
 
-            writer.inner_write(bytes!("test"));
+            writer.inner_write(bytes!("test")).unwrap();
             let mut buf = [0u8, ..4];
             match reader.inner_read(buf) {
                 Ok(4) => {
@@ -957,9 +957,9 @@ mod tests {
             assert!(!f.is_null());
             let mut file = CFile::new(f);
 
-            file.write(bytes!("test"));
+            file.write(bytes!("test")).unwrap();
             let mut buf = [0u8, ..4];
-            file.seek(0, io::SeekSet);
+            let _ = file.seek(0, io::SeekSet).unwrap();
             match file.read(buf) {
                 Ok(4) => {
                     assert_eq!(buf[0], 't' as u8);
diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs
index 2f4bec22755..ac68b1523d7 100644
--- a/src/libnative/io/net.rs
+++ b/src/libnative/io/net.rs
@@ -112,8 +112,8 @@ fn setsockopt<T>(fd: sock_t, opt: libc::c_int, val: libc::c_int,
     }
 }
 
-#[cfg(windows)] unsafe fn close(sock: sock_t) { libc::closesocket(sock); }
-#[cfg(unix)]    unsafe fn close(sock: sock_t) { libc::close(sock); }
+#[cfg(windows)] unsafe fn close(sock: sock_t) { let _ = libc::closesocket(sock); }
+#[cfg(unix)]    unsafe fn close(sock: sock_t) { let _ = libc::close(sock); }
 
 fn sockname(fd: sock_t,
             f: extern "system" unsafe fn(sock_t, *mut libc::sockaddr,
diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs
index 13dd4298777..c2522d551b6 100644
--- a/src/libnative/io/process.rs
+++ b/src/libnative/io/process.rs
@@ -102,9 +102,9 @@ impl Process {
                                    cwd.as_ref(), in_fd, out_fd, err_fd);
 
         unsafe {
-            for pipe in in_pipe.iter() { libc::close(pipe.input); }
-            for pipe in out_pipe.iter() { libc::close(pipe.out); }
-            for pipe in err_pipe.iter() { libc::close(pipe.out); }
+            for pipe in in_pipe.iter() { let _ = libc::close(pipe.input); }
+            for pipe in out_pipe.iter() { let _ = libc::close(pipe.out); }
+            for pipe in err_pipe.iter() { let _ = libc::close(pipe.out); }
         }
 
         match res {
@@ -163,8 +163,8 @@ impl rtio::RtioProcess for Process {
 
         #[cfg(not(windows))]
         unsafe fn killpid(pid: pid_t, signal: int) -> Result<(), io::IoError> {
-            libc::funcs::posix88::signal::kill(pid, signal as c_int);
-            Ok(())
+            let r = libc::funcs::posix88::signal::kill(pid, signal as c_int);
+            super::mkerr_libc(r)
         }
     }
 }
@@ -445,24 +445,24 @@ fn spawn_process_os(prog: &str, args: &[~str],
         rustrt::rust_unset_sigprocmask();
 
         if in_fd == -1 {
-            libc::close(libc::STDIN_FILENO);
+            let _ = libc::close(libc::STDIN_FILENO);
         } else if retry(|| dup2(in_fd, 0)) == -1 {
             fail!("failure in dup2(in_fd, 0): {}", os::last_os_error());
         }
         if out_fd == -1 {
-            libc::close(libc::STDOUT_FILENO);
+            let _ = libc::close(libc::STDOUT_FILENO);
         } else if retry(|| dup2(out_fd, 1)) == -1 {
             fail!("failure in dup2(out_fd, 1): {}", os::last_os_error());
         }
         if err_fd == -1 {
-            libc::close(libc::STDERR_FILENO);
+            let _ = libc::close(libc::STDERR_FILENO);
         } else if retry(|| dup2(err_fd, 2)) == -1 {
             fail!("failure in dup3(err_fd, 2): {}", os::last_os_error());
         }
         // close all other fds
         for fd in range(3, getdtablesize()).rev() {
             if fd != output.fd() {
-                close(fd as c_int);
+                let _ = close(fd as c_int);
             }
         }
 
@@ -478,7 +478,7 @@ fn spawn_process_os(prog: &str, args: &[~str],
             }
         });
         with_argv(prog, args, |argv| {
-            execvp(*argv, argv);
+            let _ = execvp(*argv, argv);
             let errno = os::errno();
             let bytes = [
                 (errno << 24) as u8,
diff --git a/src/libnative/io/timer_other.rs b/src/libnative/io/timer_other.rs
index bc005f2fe8d..cda239329dc 100644
--- a/src/libnative/io/timer_other.rs
+++ b/src/libnative/io/timer_other.rs
@@ -187,7 +187,7 @@ fn helper(input: libc::c_int, messages: Port<Req>) {
 
                 // drain the file descriptor
                 let mut buf = [0];
-                fd.inner_read(buf).unwrap();
+                assert_eq!(fd.inner_read(buf).unwrap(), 1);
             }
 
             -1 if os::errno() == libc::EINTR as int => {}
@@ -216,7 +216,8 @@ impl Timer {
     }
 
     pub fn sleep(ms: u64) {
-        unsafe { libc::usleep((ms * 1000) as libc::c_uint); }
+        // FIXME: this can fail because of EINTR, what do do?
+        let _ = unsafe { libc::usleep((ms * 1000) as libc::c_uint) };
     }
 
     fn inner(&mut self) -> ~Inner {