Skip to content

Commit 1069f6b

Browse files
committed
Fix handling of as_file_handle error for fullfsync
1 parent 045bcab commit 1069f6b

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/shims/posix/fs.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
501501
let &[_, _] = check_arg_count(args)?;
502502
if let Some(file_descriptor) = this.machine.file_handler.handles.get(&fd) {
503503
// FIXME: Support fullfsync for all FDs
504-
match file_descriptor.as_file_handle() {
505-
Ok(FileHandle { file, writable }) => {
506-
let io_result = maybe_sync_file(&file, *writable, File::sync_all);
507-
this.try_unwrap_io_result(io_result)
508-
},
509-
Err(_) => this.handle_not_found(),
510-
}
504+
let FileHandle { file, writable } = file_descriptor.as_file_handle()?;
505+
let io_result = maybe_sync_file(&file, *writable, File::sync_all);
506+
this.try_unwrap_io_result(io_result)
511507
} else {
512508
this.handle_not_found()
513509
}
@@ -1365,10 +1361,7 @@ impl FileMetadata {
13651361
) -> InterpResult<'tcx, Option<FileMetadata>> {
13661362
let option = ecx.machine.file_handler.handles.get(&fd);
13671363
let file = match option {
1368-
Some(file_descriptor) => {
1369-
let FileHandle { file, writable: _ } = file_descriptor.as_file_handle()?;
1370-
file
1371-
},
1364+
Some(file_descriptor) => &file_descriptor.as_file_handle()?.file,
13721365
None => return ecx.handle_not_found().map(|_: i32| None),
13731366
};
13741367
let metadata = file.metadata();

0 commit comments

Comments
 (0)