Skip to content

Commit c13a625

Browse files
committed
Flag Result as #[must_use] and deal with fallout.
1 parent 9896beb commit c13a625

File tree

8 files changed

+20
-21
lines changed

8 files changed

+20
-21
lines changed

src/libnative/io/file.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ impl io::Reader for FileDesc {
118118

119119
impl io::Writer for FileDesc {
120120
fn write(&mut self, buf: &[u8]) {
121-
self.inner_write(buf);
121+
match self.inner_write(buf) {
122+
Ok(()) => {}
123+
Err(e) => { io::io_error::cond.raise(e); }
124+
}
122125
}
123126
}
124127

@@ -276,7 +279,7 @@ impl rtio::RtioFileStream for FileDesc {
276279
_ => Ok(())
277280
}
278281
};
279-
self.seek(orig_pos as i64, io::SeekSet);
282+
let _ = self.seek(orig_pos as i64, io::SeekSet);
280283
return ret;
281284
}
282285
#[cfg(unix)]
@@ -383,12 +386,10 @@ impl rtio::RtioFileStream for CFile {
383386
}
384387

385388
fn pread(&mut self, buf: &mut [u8], offset: u64) -> Result<int, IoError> {
386-
self.flush();
387-
self.fd.pread(buf, offset)
389+
self.flush().and_then(|()| self.fd.pread(buf, offset))
388390
}
389391
fn pwrite(&mut self, buf: &[u8], offset: u64) -> Result<(), IoError> {
390-
self.flush();
391-
self.fd.pwrite(buf, offset)
392+
self.flush().and_then(|()| self.fd.pwrite(buf, offset))
392393
}
393394
fn seek(&mut self, pos: i64, style: io::SeekStyle) -> Result<u64, IoError> {
394395
let whence = match style {
@@ -412,16 +413,13 @@ impl rtio::RtioFileStream for CFile {
412413
}
413414
}
414415
fn fsync(&mut self) -> Result<(), IoError> {
415-
self.flush();
416-
self.fd.fsync()
416+
self.flush().and_then(|()| self.fd.fsync())
417417
}
418418
fn datasync(&mut self) -> Result<(), IoError> {
419-
self.flush();
420-
self.fd.fsync()
419+
self.flush().and_then(|()| self.fd.fsync())
421420
}
422421
fn truncate(&mut self, offset: i64) -> Result<(), IoError> {
423-
self.flush();
424-
self.fd.truncate(offset)
422+
self.flush().and_then(|()| self.fd.truncate(offset))
425423
}
426424
}
427425

src/libnative/io/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ fn spawn_process_os(prog: &str, args: &[~str],
486486
(errno << 8) as u8,
487487
(errno << 0) as u8,
488488
];
489-
output.inner_write(bytes);
489+
assert!(output.inner_write(bytes).is_ok());
490490
intrinsics::abort();
491491
})
492492
}

src/libnative/io/timer_helper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ mod imp {
101101
}
102102

103103
pub fn signal(fd: libc::c_int) {
104-
FileDesc::new(fd, false).inner_write([0]);
104+
FileDesc::new(fd, false).inner_write([0]).unwrap();
105105
}
106106

107107
pub fn close(fd: libc::c_int) {

src/libnative/io/timer_other.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ fn helper(input: libc::c_int, messages: Port<Req>) {
187187

188188
// drain the file descriptor
189189
let mut buf = [0];
190-
fd.inner_read(buf);
190+
fd.inner_read(buf).unwrap();
191191
}
192192

193193
-1 if os::errno() == libc::EINTR as int => {}

src/libnative/io/timer_timerfd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ fn helper(input: libc::c_int, messages: Port<Req>) {
9898
if fd == input {
9999
let mut buf = [0, ..1];
100100
// drain the input file descriptor of its input
101-
FileDesc::new(fd, false).inner_read(buf);
101+
FileDesc::new(fd, false).inner_read(buf).unwrap();
102102
incoming = true;
103103
} else {
104104
let mut bits = [0, ..8];
105105
// drain the timerfd of how many times its fired
106106
//
107107
// FIXME: should this perform a send() this number of
108108
// times?
109-
FileDesc::new(fd, false).inner_read(bits);
109+
FileDesc::new(fd, false).inner_read(bits).unwrap();
110110
let remove = {
111111
match map.find(&fd).expect("fd unregistered") {
112112
&(ref c, oneshot) => !c.try_send(()) || oneshot

src/librustuv/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl Drop for FileWatcher {
389389
}
390390
}
391391
rtio::CloseSynchronously => {
392-
execute_nop(|req, cb| unsafe {
392+
let _ = execute_nop(|req, cb| unsafe {
393393
uvll::uv_fs_close(self.loop_.handle, req, self.fd, cb)
394394
});
395395
}

src/libstd/io/fs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl File {
175175
///
176176
/// This function will raise on the `io_error` condition on failure.
177177
pub fn fsync(&mut self) {
178-
self.fd.fsync().map_err(|e| io_error::cond.raise(e));
178+
let _ = self.fd.fsync().map_err(|e| io_error::cond.raise(e));
179179
}
180180

181181
/// This function is similar to `fsync`, except that it may not synchronize
@@ -187,7 +187,7 @@ impl File {
187187
///
188188
/// This function will raise on the `io_error` condition on failure.
189189
pub fn datasync(&mut self) {
190-
self.fd.datasync().map_err(|e| io_error::cond.raise(e));
190+
let _ = self.fd.datasync().map_err(|e| io_error::cond.raise(e));
191191
}
192192

193193
/// Either truncates or extends the underlying file, updating the size of
@@ -203,7 +203,7 @@ impl File {
203203
///
204204
/// On error, this function will raise on the `io_error` condition.
205205
pub fn truncate(&mut self, size: i64) {
206-
self.fd.truncate(size).map_err(|e| io_error::cond.raise(e));
206+
let _ = self.fd.truncate(size).map_err(|e| io_error::cond.raise(e));
207207
}
208208

209209
/// Tests whether this stream has reached EOF.

src/libstd/result.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use to_str::ToStr;
2020

2121
/// `Result` is a type that represents either success (`Ok`) or failure (`Err`).
2222
#[deriving(Clone, DeepClone, Eq, Ord, TotalEq, TotalOrd, ToStr)]
23+
#[must_use]
2324
pub enum Result<T, E> {
2425
/// Contains the success value
2526
Ok(T),

0 commit comments

Comments
 (0)