summaryrefslogtreecommitdiff
path: root/src/sys/quota.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-09 01:05:23 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-09 01:05:23 +0000
commitf1b12d6b1b8bf6d8ad41e7b2967b95c6f876745c (patch)
treedbbf94ee5189b13ea4d448ba63512b43f85b4ba8 /src/sys/quota.rs
parent5a3ac8df3fa2de86477d961d8b5720b1d283b2d5 (diff)
parentca035734df2e3dfeb866cbfee51de7b582be83f5 (diff)
downloadnix-f1b12d6b1b8bf6d8ad41e7b2967b95c6f876745c.zip
Merge #995
995: Replace try! with ? r=asomers a=asomers try! is not available in Rust 2018. It would be premature to convert the entire project to Rust 2018, since that would bump the minimum compiler to 1.31.0. But his change will help us when we do convert it eventually. Co-authored-by: Alan Somers <asomers@gmail.com>
Diffstat (limited to 'src/sys/quota.rs')
-rw-r--r--src/sys/quota.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/sys/quota.rs b/src/sys/quota.rs
index b4cac1dc..14c04629 100644
--- a/src/sys/quota.rs
+++ b/src/sys/quota.rs
@@ -231,12 +231,10 @@ impl Dqblk {
fn quotactl<P: ?Sized + NixPath>(cmd: QuotaCmd, special: Option<&P>, id: c_int, addr: *mut c_char) -> Result<()> {
unsafe {
Errno::clear();
- let res = try!(
- match special {
- Some(dev) => dev.with_nix_path(|path| libc::quotactl(cmd.as_int(), path.as_ptr(), id, addr)),
- None => Ok(libc::quotactl(cmd.as_int(), ptr::null(), id, addr)),
- }
- );
+ let res = match special {
+ Some(dev) => dev.with_nix_path(|path| libc::quotactl(cmd.as_int(), path.as_ptr(), id, addr)),
+ None => Ok(libc::quotactl(cmd.as_int(), ptr::null(), id, addr)),
+ }?;
Errno::result(res).map(drop)
}
@@ -244,11 +242,11 @@ fn quotactl<P: ?Sized + NixPath>(cmd: QuotaCmd, special: Option<&P>, id: c_int,
/// Turn on disk quotas for a block device.
pub fn quotactl_on<P: ?Sized + NixPath>(which: QuotaType, special: &P, format: QuotaFmt, quota_file: &P) -> Result<()> {
- try!(quota_file.with_nix_path(|path| {
+ quota_file.with_nix_path(|path| {
let mut path_copy = path.to_bytes_with_nul().to_owned();
let p: *mut c_char = path_copy.as_mut_ptr() as *mut c_char;
quotactl(QuotaCmd(QuotaSubCmd::Q_QUOTAON, which), Some(special), format as c_int, p)
- }))
+ })?
}
/// Disable disk quotas for a block device.