rustuv: Require all results are used and fix fallout

This commit is contained in:
Alex Crichton 2014-01-30 14:28:36 -08:00
parent ae581a0103
commit 94f2dfa8f6
11 changed files with 34 additions and 32 deletions

View File

@ -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) {

View File

@ -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() {

View File

@ -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));
}
}

View File

@ -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) {

View File

@ -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
}
}

View File

@ -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();

View File

@ -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();

View File

@ -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 {

View File

@ -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,

View File

@ -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.

View File

@ -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) }
}