diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2014-06-17 17:14:55 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2014-06-18 01:27:42 -0400 |
| commit | bb0a42745f7a951c298b7bc2e07f7ba1fee14100 (patch) | |
| tree | 0ba014610e3d3160d8ef17e337634d94753d33ea /src/libstd | |
| parent | 2fd618e77accd37426819952ad443e50bb3c9015 (diff) | |
| download | rust-bb0a42745f7a951c298b7bc2e07f7ba1fee14100.tar.gz rust-bb0a42745f7a951c298b7bc2e07f7ba1fee14100.zip | |
fix signatures of mmap-related functions from libc
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/os.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/libstd/os.rs b/src/libstd/os.rs index dfbf61cc890..4d58d4674bf 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1338,7 +1338,6 @@ impl MemoryMap { /// `ErrZeroLength`. pub fn new(min_len: uint, options: &[MapOption]) -> Result<MemoryMap, MapError> { use libc::off_t; - use cmp::Equiv; if min_len == 0 { return Err(ErrZeroLength) @@ -1371,10 +1370,10 @@ impl MemoryMap { if fd == -1 && !custom_flags { flags |= libc::MAP_ANON; } let r = unsafe { - libc::mmap(addr as *c_void, len as libc::size_t, prot, flags, fd, - offset) + libc::mmap(addr as *mut c_void, len as libc::size_t, prot, flags, + fd, offset) }; - if r.equiv(&libc::MAP_FAILED) { + if r == libc::MAP_FAILED { Err(match errno() as c_int { libc::EACCES => ErrFdNotAvail, libc::EBADF => ErrInvalidFd, @@ -1410,8 +1409,8 @@ impl Drop for MemoryMap { if self.len == 0 { /* workaround for dummy_stack */ return; } unsafe { - // FIXME: what to do if this fails? - let _ = libc::munmap(self.data as *c_void, self.len as libc::size_t); + // `munmap` only fails due to logic errors + libc::munmap(self.data as *mut c_void, self.len as libc::size_t); } } } |
