Skip to content

libnative/io/file_unix: remove superfluous retry(). #16964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions src/libnative/io/file_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl rtio::RtioFileStream for FileDesc {

fn fstat(&mut self) -> IoResult<rtio::FileStat> {
let mut stat: libc::stat = unsafe { mem::zeroed() };
match retry(|| unsafe { libc::fstat(self.fd(), &mut stat) }) {
match unsafe { libc::fstat(self.fd(), &mut stat) } {
0 => Ok(mkstat(&stat)),
_ => Err(super::last_error()),
}
Expand Down Expand Up @@ -346,9 +346,7 @@ pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess)
}

pub fn mkdir(p: &CString, mode: uint) -> IoResult<()> {
super::mkerr_libc(retry(|| unsafe {
libc::mkdir(p.as_ptr(), mode as libc::mode_t)
}))
super::mkerr_libc(unsafe { libc::mkdir(p.as_ptr(), mode as libc::mode_t) })
}

pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
Expand Down Expand Up @@ -393,13 +391,11 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
}

pub fn unlink(p: &CString) -> IoResult<()> {
super::mkerr_libc(retry(|| unsafe { libc::unlink(p.as_ptr()) }))
super::mkerr_libc(unsafe { libc::unlink(p.as_ptr()) })
}

pub fn rename(old: &CString, new: &CString) -> IoResult<()> {
super::mkerr_libc(retry(|| unsafe {
libc::rename(old.as_ptr(), new.as_ptr())
}))
super::mkerr_libc(unsafe { libc::rename(old.as_ptr(), new.as_ptr()) })
}

pub fn chmod(p: &CString, mode: uint) -> IoResult<()> {
Expand All @@ -409,9 +405,7 @@ pub fn chmod(p: &CString, mode: uint) -> IoResult<()> {
}

pub fn rmdir(p: &CString) -> IoResult<()> {
super::mkerr_libc(retry(|| unsafe {
libc::rmdir(p.as_ptr())
}))
super::mkerr_libc(unsafe { libc::rmdir(p.as_ptr()) })
}

pub fn chown(p: &CString, uid: int, gid: int) -> IoResult<()> {
Expand All @@ -428,10 +422,10 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
len = 1024; // FIXME: read PATH_MAX from C ffi?
}
let mut buf: Vec<u8> = Vec::with_capacity(len as uint);
match retry(|| unsafe {
match unsafe {
libc::readlink(p, buf.as_ptr() as *mut libc::c_char,
len as libc::size_t) as libc::c_int
}) {
} {
-1 => Err(super::last_error()),
n => {
assert!(n > 0);
Expand All @@ -442,15 +436,11 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
}

pub fn symlink(src: &CString, dst: &CString) -> IoResult<()> {
super::mkerr_libc(retry(|| unsafe {
libc::symlink(src.as_ptr(), dst.as_ptr())
}))
super::mkerr_libc(unsafe { libc::symlink(src.as_ptr(), dst.as_ptr()) })
}

pub fn link(src: &CString, dst: &CString) -> IoResult<()> {
super::mkerr_libc(retry(|| unsafe {
libc::link(src.as_ptr(), dst.as_ptr())
}))
super::mkerr_libc(unsafe { libc::link(src.as_ptr(), dst.as_ptr()) })
}

fn mkstat(stat: &libc::stat) -> rtio::FileStat {
Expand Down Expand Up @@ -489,15 +479,15 @@ fn mkstat(stat: &libc::stat) -> rtio::FileStat {

pub fn stat(p: &CString) -> IoResult<rtio::FileStat> {
let mut stat: libc::stat = unsafe { mem::zeroed() };
match retry(|| unsafe { libc::stat(p.as_ptr(), &mut stat) }) {
match unsafe { libc::stat(p.as_ptr(), &mut stat) } {
0 => Ok(mkstat(&stat)),
_ => Err(super::last_error()),
}
}

pub fn lstat(p: &CString) -> IoResult<rtio::FileStat> {
let mut stat: libc::stat = unsafe { mem::zeroed() };
match retry(|| unsafe { libc::lstat(p.as_ptr(), &mut stat) }) {
match unsafe { libc::lstat(p.as_ptr(), &mut stat) } {
0 => Ok(mkstat(&stat)),
_ => Err(super::last_error()),
}
Expand All @@ -508,9 +498,7 @@ pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
actime: (atime / 1000) as libc::time_t,
modtime: (mtime / 1000) as libc::time_t,
};
super::mkerr_libc(retry(|| unsafe {
libc::utime(p.as_ptr(), &buf)
}))
super::mkerr_libc(unsafe { libc::utime(p.as_ptr(), &buf) })
}

#[cfg(test)]
Expand Down