]> git.lizzy.rs Git - rust.git/commitdiff
Style fixes
authorDavid Cook <divergentdave@gmail.com>
Fri, 31 Jan 2020 00:31:34 +0000 (18:31 -0600)
committerDavid Cook <divergentdave@gmail.com>
Tue, 18 Feb 2020 04:24:33 +0000 (22:24 -0600)
src/shims/fs.rs

index b766dd6de47aa94841bed542f470bf50e3adbd09..d17ef79f0eed3c8423129a9736f7f58d2e2315e8 100644 (file)
@@ -142,12 +142,11 @@ fn fcntl(
         } else if cmd == this.eval_libc_i32("F_DUPFD")? || cmd == this.eval_libc_i32("F_DUPFD_CLOEXEC")? {
             // Note that we always assume the FD_CLOEXEC flag is set for every open file, in part
             // because exec() isn't supported. The F_DUPFD and F_DUPFD_CLOEXEC commands only
-            // differ in whether the FD_CLOEXEC flag is pre-set on the duplicated file descriptor,
+            // differ in whether the FD_CLOEXEC flag is pre-set on the new file descriptor,
             // thus they can share the same implementation here.
-            let arg = match arg_op {
-                Some(arg_op) => this.read_scalar(arg_op)?.to_i32()?,
-                None => throw_unsup_format!("fcntl with command F_DUPFD or F_DUPFD_CLOEXEC requires a third argument"),
-            };
+            let arg_op = arg_op
+                .ok_or_else(|| err_unsup_format!("fcntl with command F_DUPFD or F_DUPFD_CLOEXEC requires a third argument"))?;
+            let arg = this.read_scalar(arg_op)?.to_i32()?;
             let fh = &mut this.machine.file_handler;
             let (file_result, writable) = match fh.handles.get(&fd) {
                 Some(original) => (original.file.try_clone(), original.writable),