From: Samrat Man Singh Date: Sat, 8 Aug 2020 11:58:41 +0000 (+0530) Subject: Fix handling of as_file_handle error for `fullfsync` X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=1069f6b17468a48af5a8ab441bf355ac955f4596;p=rust.git Fix handling of as_file_handle error for `fullfsync` --- 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 @@ 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> { 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();