]> git.lizzy.rs Git - rust.git/commitdiff
Fix handling of as_file_handle error for `fullfsync`
authorSamrat Man Singh <samratmansingh@gmail.com>
Sat, 8 Aug 2020 11:58:41 +0000 (17:28 +0530)
committerSamrat Man Singh <samratmansingh@gmail.com>
Sat, 8 Aug 2020 11:58:41 +0000 (17:28 +0530)
src/shims/posix/fs.rs

index ec6fb7c537356fb5a1fac79085019086cc12ef07..e0b2837cae908f0c8ee198a334e2a1aa09a7c1f7 100644 (file)
@@ -501,13 +501,9 @@ fn fcntl(
             let &[_, _] = check_arg_count(args)?;
             if let Some(file_descriptor) = this.machine.file_handler.handles.get(&fd) {
                 // FIXME: Support fullfsync for all FDs
-                match file_descriptor.as_file_handle() {
-                    Ok(FileHandle { file, writable }) => {
-                        let io_result = maybe_sync_file(&file, *writable, File::sync_all);
-                        this.try_unwrap_io_result(io_result)
-                    },
-                    Err(_) => this.handle_not_found(),
-                }
+                let FileHandle { file, writable } = file_descriptor.as_file_handle()?;
+                let io_result = maybe_sync_file(&file, *writable, File::sync_all);
+                this.try_unwrap_io_result(io_result)
             } else {
                 this.handle_not_found()
             }
@@ -1365,10 +1361,7 @@ fn from_fd<'tcx, 'mir>(
     ) -> InterpResult<'tcx, Option<FileMetadata>> {
         let option = ecx.machine.file_handler.handles.get(&fd);
         let file = match option {
-            Some(file_descriptor) => {
-                let FileHandle { file, writable: _ } = file_descriptor.as_file_handle()?;
-                file
-            },
+            Some(file_descriptor) => &file_descriptor.as_file_handle()?.file,
             None => return ecx.handle_not_found().map(|_: i32| None),
         };
         let metadata = file.metadata();