Skip to content

Commit b48e1b1

Browse files
committed
Rename all file_descriptor variables to file_description to match the naming scheme of the types
1 parent 4742a81 commit b48e1b1

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

src/tools/miri/src/shims/unix/fd.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
320320
if new_fd != old_fd {
321321
// Close new_fd if it is previously opened.
322322
// If old_fd and new_fd point to the same description, then `dup_fd` ensures we keep the underlying file description alive.
323-
if let Some(file_descriptor) = this.machine.fds.fds.insert(new_fd, dup_fd) {
323+
if let Some(file_description) = this.machine.fds.fds.insert(new_fd, dup_fd) {
324324
// Ignore close error (not interpreter's) according to dup2() doc.
325-
file_descriptor.close(this.machine.communicate())?.ok();
325+
file_description.close(this.machine.communicate())?.ok();
326326
}
327327
}
328328
Ok(new_fd)
@@ -389,10 +389,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
389389

390390
let fd = this.read_scalar(fd_op)?.to_i32()?;
391391

392-
let Some(file_descriptor) = this.machine.fds.remove(fd) else {
392+
let Some(file_description) = this.machine.fds.remove(fd) else {
393393
return Ok(Scalar::from_i32(this.fd_not_found()?));
394394
};
395-
let result = file_descriptor.close(this.machine.communicate())?;
395+
let result = file_description.close(this.machine.communicate())?;
396396
// return `0` if close is successful
397397
let result = result.map(|()| 0i32);
398398
Ok(Scalar::from_i32(this.try_unwrap_io_result(result)?))

src/tools/miri/src/shims/unix/fs.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
483483

484484
let communicate = this.machine.communicate();
485485

486-
let Some(mut file_descriptor) = this.machine.fds.get_mut(fd) else {
486+
let Some(mut file_description) = this.machine.fds.get_mut(fd) else {
487487
return Ok(Scalar::from_i64(this.fd_not_found()?));
488488
};
489-
let result = file_descriptor
489+
let result = file_description
490490
.seek(communicate, seek_from)?
491491
.map(|offset| i64::try_from(offset).unwrap());
492-
drop(file_descriptor);
492+
drop(file_description);
493493

494494
let result = this.try_unwrap_io_result(result)?;
495495
Ok(Scalar::from_i64(result))
@@ -1176,30 +1176,30 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
11761176
return Ok(Scalar::from_i32(this.fd_not_found()?));
11771177
}
11781178

1179-
let Some(file_descriptor) = this.machine.fds.get(fd) else {
1179+
let Some(file_description) = this.machine.fds.get(fd) else {
11801180
return Ok(Scalar::from_i32(this.fd_not_found()?));
11811181
};
11821182

11831183
// FIXME: Support ftruncate64 for all FDs
11841184
let FileHandle { file, writable } =
1185-
file_descriptor.downcast_ref::<FileHandle>().ok_or_else(|| {
1185+
file_description.downcast_ref::<FileHandle>().ok_or_else(|| {
11861186
err_unsup_format!("`ftruncate64` is only supported on file-backed file descriptors")
11871187
})?;
11881188

11891189
if *writable {
11901190
if let Ok(length) = length.try_into() {
11911191
let result = file.set_len(length);
1192-
drop(file_descriptor);
1192+
drop(file_description);
11931193
let result = this.try_unwrap_io_result(result.map(|_| 0i32))?;
11941194
Ok(Scalar::from_i32(result))
11951195
} else {
1196-
drop(file_descriptor);
1196+
drop(file_description);
11971197
let einval = this.eval_libc("EINVAL");
11981198
this.set_last_error(einval)?;
11991199
Ok(Scalar::from_i32(-1))
12001200
}
12011201
} else {
1202-
drop(file_descriptor);
1202+
drop(file_description);
12031203
// The file is not writable
12041204
let einval = this.eval_libc("EINVAL");
12051205
this.set_last_error(einval)?;
@@ -1229,16 +1229,16 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
12291229

12301230
fn ffullsync_fd(&mut self, fd: i32) -> InterpResult<'tcx, i32> {
12311231
let this = self.eval_context_mut();
1232-
let Some(file_descriptor) = this.machine.fds.get(fd) else {
1232+
let Some(file_description) = this.machine.fds.get(fd) else {
12331233
return Ok(this.fd_not_found()?);
12341234
};
12351235
// Only regular files support synchronization.
12361236
let FileHandle { file, writable } =
1237-
file_descriptor.downcast_ref::<FileHandle>().ok_or_else(|| {
1237+
file_description.downcast_ref::<FileHandle>().ok_or_else(|| {
12381238
err_unsup_format!("`fsync` is only supported on file-backed file descriptors")
12391239
})?;
12401240
let io_result = maybe_sync_file(file, *writable, File::sync_all);
1241-
drop(file_descriptor);
1241+
drop(file_description);
12421242
this.try_unwrap_io_result(io_result)
12431243
}
12441244

@@ -1254,16 +1254,16 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
12541254
return this.fd_not_found();
12551255
}
12561256

1257-
let Some(file_descriptor) = this.machine.fds.get(fd) else {
1257+
let Some(file_description) = this.machine.fds.get(fd) else {
12581258
return Ok(this.fd_not_found()?);
12591259
};
12601260
// Only regular files support synchronization.
12611261
let FileHandle { file, writable } =
1262-
file_descriptor.downcast_ref::<FileHandle>().ok_or_else(|| {
1262+
file_description.downcast_ref::<FileHandle>().ok_or_else(|| {
12631263
err_unsup_format!("`fdatasync` is only supported on file-backed file descriptors")
12641264
})?;
12651265
let io_result = maybe_sync_file(file, *writable, File::sync_data);
1266-
drop(file_descriptor);
1266+
drop(file_description);
12671267
this.try_unwrap_io_result(io_result)
12681268
}
12691269

@@ -1302,18 +1302,18 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
13021302
return Ok(Scalar::from_i32(this.fd_not_found()?));
13031303
}
13041304

1305-
let Some(file_descriptor) = this.machine.fds.get(fd) else {
1305+
let Some(file_description) = this.machine.fds.get(fd) else {
13061306
return Ok(Scalar::from_i32(this.fd_not_found()?));
13071307
};
13081308
// Only regular files support synchronization.
13091309
let FileHandle { file, writable } =
1310-
file_descriptor.downcast_ref::<FileHandle>().ok_or_else(|| {
1310+
file_description.downcast_ref::<FileHandle>().ok_or_else(|| {
13111311
err_unsup_format!(
13121312
"`sync_data_range` is only supported on file-backed file descriptors"
13131313
)
13141314
})?;
13151315
let io_result = maybe_sync_file(file, *writable, File::sync_data);
1316-
drop(file_descriptor);
1316+
drop(file_description);
13171317
Ok(Scalar::from_i32(this.try_unwrap_io_result(io_result)?))
13181318
}
13191319

@@ -1609,11 +1609,11 @@ impl FileMetadata {
16091609
ecx: &mut MiriInterpCx<'tcx>,
16101610
fd: i32,
16111611
) -> InterpResult<'tcx, Option<FileMetadata>> {
1612-
let Some(file_descriptor) = ecx.machine.fds.get(fd) else {
1612+
let Some(file_description) = ecx.machine.fds.get(fd) else {
16131613
return ecx.fd_not_found().map(|_: i32| None);
16141614
};
16151615

1616-
let file = &file_descriptor
1616+
let file = &file_description
16171617
.downcast_ref::<FileHandle>()
16181618
.ok_or_else(|| {
16191619
err_unsup_format!(
@@ -1623,7 +1623,7 @@ impl FileMetadata {
16231623
.file;
16241624

16251625
let metadata = file.metadata();
1626-
drop(file_descriptor);
1626+
drop(file_description);
16271627
FileMetadata::from_meta(ecx, metadata)
16281628
}
16291629

0 commit comments

Comments
 (0)