about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-01-30 14:28:36 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-02-03 09:32:35 -0800
commit94f2dfa8f632542bfb7260ca4b0aadce24061592 (patch)
tree209a36ace5391cb488b0d8fbe997aa0cdffe878b /src
parentae581a010363b26ef6bae60145ebd17343a343b0 (diff)
downloadrust-94f2dfa8f632542bfb7260ca4b0aadce24061592.tar.gz
rust-94f2dfa8f632542bfb7260ca4b0aadce24061592.zip
rustuv: Require all results are used and fix fallout
Diffstat (limited to 'src')
-rw-r--r--src/librustuv/file.rs9
-rw-r--r--src/librustuv/homing.rs4
-rw-r--r--src/librustuv/idle.rs4
-rw-r--r--src/librustuv/lib.rs5
-rw-r--r--src/librustuv/macros.rs6
-rw-r--r--src/librustuv/net.rs12
-rw-r--r--src/librustuv/pipe.rs2
-rw-r--r--src/librustuv/queue.rs2
-rw-r--r--src/librustuv/signal.rs2
-rw-r--r--src/librustuv/timer.rs18
-rw-r--r--src/librustuv/uvio.rs2
11 files changed, 34 insertions, 32 deletions
diff --git a/src/librustuv/file.rs b/src/librustuv/file.rs
index 31afa7b5c7c..2cef2664c2f 100644
--- a/src/librustuv/file.rs
+++ b/src/librustuv/file.rs
@@ -140,9 +140,9 @@ impl FsRequest {
             let mut paths = ~[];
             let path = CString::new(path.with_ref(|p| p), false);
             let parent = Path::new(path);
-            c_str::from_c_multistring(req.get_ptr() as *libc::c_char,
-                                      Some(req.get_result() as uint),
-                                      |rel| {
+            let _ = c_str::from_c_multistring(req.get_ptr() as *libc::c_char,
+                                              Some(req.get_result() as uint),
+                                              |rel| {
                 let p = rel.as_bytes();
                 paths.push(parent.join(p.slice_to(rel.len())));
             });
@@ -378,7 +378,8 @@ impl Drop for FileWatcher {
             rtio::CloseAsynchronously => {
                 unsafe {
                     let req = uvll::malloc_req(uvll::UV_FS);
-                    uvll::uv_fs_close(self.loop_.handle, req, self.fd, close_cb);
+                    assert_eq!(uvll::uv_fs_close(self.loop_.handle, req,
+                                                 self.fd, close_cb), 0);
                 }
 
                 extern fn close_cb(req: *uvll::uv_fs_t) {
diff --git a/src/librustuv/homing.rs b/src/librustuv/homing.rs
index 8d3e71312cd..a2f3457a943 100644
--- a/src/librustuv/homing.rs
+++ b/src/librustuv/homing.rs
@@ -176,7 +176,7 @@ mod test {
         });
 
         let task = pool.task(TaskOpts::new(), proc() {
-            port.recv();
+            drop(port.recv());
         });
         pool.spawn_sched().send(sched::TaskFromFriend(task));
 
@@ -197,7 +197,7 @@ mod test {
             let listener = UdpWatcher::bind(local_loop(), addr2);
             chan.send((listener.unwrap(), addr1));
             let mut listener = UdpWatcher::bind(local_loop(), addr1).unwrap();
-            listener.sendto([1, 2, 3, 4], addr2);
+            listener.sendto([1, 2, 3, 4], addr2).unwrap();
         });
 
         let task = pool.task(TaskOpts::new(), proc() {
diff --git a/src/librustuv/idle.rs b/src/librustuv/idle.rs
index 3d6e81d0d6f..dafd3dbe1bc 100644
--- a/src/librustuv/idle.rs
+++ b/src/librustuv/idle.rs
@@ -52,7 +52,7 @@ impl IdleWatcher {
                 let data = uvll::get_data_for_uv_handle(handle);
                 let f: ~proc() = cast::transmute(data);
                 (*f)();
-                uvll::uv_idle_stop(handle);
+                assert_eq!(uvll::uv_idle_stop(handle), 0);
                 uvll::uv_close(handle, close_cb);
             }
         }
@@ -122,7 +122,7 @@ mod test {
                     }
                 }
             };
-            task.wake().map(|t| t.reawaken(true));
+            let _ = task.wake().map(|t| t.reawaken(true));
         }
     }
 
diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs
index 0b889e17a44..f945c0972ca 100644
--- a/src/librustuv/lib.rs
+++ b/src/librustuv/lib.rs
@@ -40,6 +40,7 @@ via `close` and `delete` methods.
 #[crate_type = "dylib"];
 
 #[feature(macro_rules)];
+#[deny(unused_result, unused_must_use)];
 
 #[cfg(test)] extern mod green;
 
@@ -207,7 +208,7 @@ fn wait_until_woken_after(slot: *mut Option<BlockedTask>, f: ||) {
 
 fn wakeup(slot: &mut Option<BlockedTask>) {
     assert!(slot.is_some());
-    slot.take_unwrap().wake().map(|t| t.reawaken(true));
+    let _ = slot.take_unwrap().wake().map(|t| t.reawaken(true));
 }
 
 pub struct Request {
@@ -276,7 +277,7 @@ impl Loop {
     pub fn wrap(handle: *uvll::uv_loop_t) -> Loop { Loop { handle: handle } }
 
     pub fn run(&mut self) {
-        unsafe { uvll::uv_run(self.handle, uvll::RUN_DEFAULT) };
+        assert_eq!(unsafe { uvll::uv_run(self.handle, uvll::RUN_DEFAULT) }, 0);
     }
 
     pub fn close(&mut self) {
diff --git a/src/librustuv/macros.rs b/src/librustuv/macros.rs
index afd36f8ddd1..75b68e3a528 100644
--- a/src/librustuv/macros.rs
+++ b/src/librustuv/macros.rs
@@ -34,11 +34,11 @@ pub fn dumb_println(args: &fmt::Arguments) {
     struct Stderr;
     impl io::Writer for Stderr {
         fn write(&mut self, data: &[u8]) -> io::IoResult<()> {
-            unsafe {
+            let _ = unsafe {
                 libc::write(libc::STDERR_FILENO,
                             data.as_ptr() as *libc::c_void,
-                            data.len() as libc::size_t);
-            }
+                            data.len() as libc::size_t)
+            };
             Ok(()) // just ignore the errors
         }
     }
diff --git a/src/librustuv/net.rs b/src/librustuv/net.rs
index 8919ecfa97e..5461fc6272d 100644
--- a/src/librustuv/net.rs
+++ b/src/librustuv/net.rs
@@ -953,11 +953,11 @@ mod test {
         spawn(proc() {
             let port2 = port.recv();
             let mut stream = TcpWatcher::connect(local_loop(), addr).unwrap();
-            stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
-            stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
+            stream.write([0, 1, 2, 3, 4, 5, 6, 7]).unwrap();
+            stream.write([0, 1, 2, 3, 4, 5, 6, 7]).unwrap();
             port2.recv();
-            stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
-            stream.write([0, 1, 2, 3, 4, 5, 6, 7]);
+            stream.write([0, 1, 2, 3, 4, 5, 6, 7]).unwrap();
+            stream.write([0, 1, 2, 3, 4, 5, 6, 7]).unwrap();
             port2.recv();
         });
 
@@ -1008,7 +1008,7 @@ mod test {
         while stream.is_err() {
             stream = TcpWatcher::connect(local_loop(), addr);
         }
-        stream.unwrap().write([0, 1, 2, 3, 4, 5, 6, 7]);
+        stream.unwrap().write([0, 1, 2, 3, 4, 5, 6, 7]).unwrap();
     }
 
     #[should_fail] #[test]
@@ -1028,7 +1028,7 @@ mod test {
             let w = TcpListener::bind(local_loop(), addr).unwrap();
             let mut w = w.listen().unwrap();
             chan.send(());
-            w.accept();
+            drop(w.accept().unwrap());
         });
         port.recv();
         let _w = TcpWatcher::connect(local_loop(), addr).unwrap();
diff --git a/src/librustuv/pipe.rs b/src/librustuv/pipe.rs
index cfe86d739ab..a021a13e2d9 100644
--- a/src/librustuv/pipe.rs
+++ b/src/librustuv/pipe.rs
@@ -306,7 +306,7 @@ mod tests {
             let p = PipeListener::bind(local_loop(), &path2.to_c_str()).unwrap();
             let mut p = p.listen().unwrap();
             chan.send(());
-            p.accept();
+            drop(p.accept().unwrap());
         });
         port.recv();
         let _c = PipeWatcher::connect(local_loop(), &path.to_c_str()).unwrap();
diff --git a/src/librustuv/queue.rs b/src/librustuv/queue.rs
index 32f8d8532a2..0e1c4225caa 100644
--- a/src/librustuv/queue.rs
+++ b/src/librustuv/queue.rs
@@ -67,7 +67,7 @@ extern fn async_cb(handle: *uvll::uv_async_t, status: c_int) {
     loop {
         match state.consumer.pop() {
             mpsc::Data(Task(task)) => {
-                task.wake().map(|t| t.reawaken(true));
+                let _ = task.wake().map(|t| t.reawaken(true));
             }
             mpsc::Data(Increment) => unsafe {
                 if state.refcnt == 0 {
diff --git a/src/librustuv/signal.rs b/src/librustuv/signal.rs
index 8cb0c1f0a52..2fcc61be79b 100644
--- a/src/librustuv/signal.rs
+++ b/src/librustuv/signal.rs
@@ -86,7 +86,7 @@ mod test {
                                          chan);
 
         spawn(proc() {
-            port.try_recv();
+            let _ = port.recv_opt();
         });
 
         // when we drop the SignalWatcher we're going to destroy the channel,
diff --git a/src/librustuv/timer.rs b/src/librustuv/timer.rs
index aeda1a45175..792414238fd 100644
--- a/src/librustuv/timer.rs
+++ b/src/librustuv/timer.rs
@@ -138,11 +138,11 @@ extern fn timer_cb(handle: *uvll::uv_timer_t, status: c_int) {
 
     match timer.action.take_unwrap() {
         WakeTask(task) => {
-            task.wake().map(|t| t.reawaken(true));
+            let _ = task.wake().map(|t| t.reawaken(true));
         }
-        SendOnce(chan) => { chan.try_send(()); }
+        SendOnce(chan) => { let _ = chan.try_send(()); }
         SendMany(chan, id) => {
-            chan.try_send(());
+            let _ = chan.try_send(());
 
             // Note that the above operation could have performed some form of
             // scheduling. This means that the timer may have decided to insert
@@ -246,7 +246,7 @@ mod test {
         let timer_port = timer.period(1000);
 
         spawn(proc() {
-            timer_port.recv_opt();
+            let _ = timer_port.recv_opt();
         });
 
         // when we drop the TimerWatcher we're going to destroy the channel,
@@ -260,10 +260,10 @@ mod test {
         let timer_port = timer.period(1000);
 
         spawn(proc() {
-            timer_port.recv_opt();
+            let _ = timer_port.recv_opt();
         });
 
-        timer.oneshot(1);
+        drop(timer.oneshot(1));
     }
     #[test]
     fn reset_doesnt_switch_tasks2() {
@@ -272,7 +272,7 @@ mod test {
         let timer_port = timer.period(1000);
 
         spawn(proc() {
-            timer_port.recv_opt();
+            let _ = timer_port.recv_opt();
         });
 
         timer.sleep(1);
@@ -299,7 +299,7 @@ mod test {
     #[test]
     fn receiver_goes_away_oneshot() {
         let mut timer1 = TimerWatcher::new(local_loop());
-        timer1.oneshot(1);
+        drop(timer1.oneshot(1));
         let mut timer2 = TimerWatcher::new(local_loop());
         // while sleeping, the prevous timer should fire and not have its
         // callback do something terrible.
@@ -309,7 +309,7 @@ mod test {
     #[test]
     fn receiver_goes_away_period() {
         let mut timer1 = TimerWatcher::new(local_loop());
-        timer1.period(1);
+        drop(timer1.period(1));
         let mut timer2 = TimerWatcher::new(local_loop());
         // while sleeping, the prevous timer should fire and not have its
         // callback do something terrible.
diff --git a/src/librustuv/uvio.rs b/src/librustuv/uvio.rs
index e0bff059b0c..8a8ef4a41ec 100644
--- a/src/librustuv/uvio.rs
+++ b/src/librustuv/uvio.rs
@@ -71,7 +71,7 @@ impl Drop for UvEventLoop {
         // after the loop has been closed because during the closing of the loop
         // the handle is required to be used apparently.
         let handle = self.uvio.handle_pool.get_ref().handle();
-        self.uvio.handle_pool.take();
+        drop(self.uvio.handle_pool.take());
         self.uvio.loop_.close();
         unsafe { uvll::free_handle(handle) }
     }