From 1069f6b17468a48af5a8ab441bf355ac955f4596 Mon Sep 17 00:00:00 2001 From: Samrat Man Singh Date: Sat, 8 Aug 2020 17:28:41 +0530 Subject: [PATCH] Fix handling of as_file_handle error for `fullfsync` --- src/shims/posix/fs.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/shims/posix/fs.rs b/src/shims/posix/fs.rs index ec6fb7c5373..e0b2837cae9 100644 --- a/src/shims/posix/fs.rs +++ b/src/shims/posix/fs.rs @@ -501,13 +501,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx 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 @@ impl FileMetadata { ) -> InterpResult<'tcx, Option> { 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();