Skip to content

Commit c6bd4c9

Browse files
committed
Resolve not null/non-null inconsistency, a couple comment improvements
1 parent bf1887c commit c6bd4c9

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/shims/windows/fs.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -403,17 +403,16 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
403403
n: &OpTy<'tcx>, // ULONG
404404
byte_offset: &OpTy<'tcx>, // PLARGE_INTEGER
405405
key: &OpTy<'tcx>, // PULONG
406-
dest: &MPlaceTy<'tcx>, // NTSTATUS
406+
dest: &MPlaceTy<'tcx>, // return type: NTSTATUS
407407
) -> InterpResult<'tcx, ()> {
408-
// ^ Returns NTSTATUS (u32 on Windows)
409408
let this = self.eval_context_mut();
410409
let handle = this.read_handle(handle, "NtWriteFile")?;
411410
let event = this.read_handle(event, "NtWriteFile")?;
412411
let apc_routine = this.read_pointer(apc_routine)?;
413412
let apc_ctx = this.read_pointer(apc_ctx)?;
414413
let buf = this.read_pointer(buf)?;
415414
let count = this.read_scalar(n)?.to_u32()?;
416-
let byte_offset = this.read_target_usize(byte_offset)?; // is actually a pointer
415+
let byte_offset = this.read_target_usize(byte_offset)?; // is actually a pointer, but we only support null
417416
let key = this.read_pointer(key)?;
418417
let io_status_block =
419418
this.deref_pointer_as(io_status_block, this.windows_ty_layout("IO_STATUS_BLOCK"))?;
@@ -426,13 +425,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
426425

427426
if !this.ptr_is_null(apc_routine)? {
428427
throw_unsup_format!(
429-
"`NtWriteFile` `ApcRoutine` parameter is not null, which is unsupported"
428+
"`NtWriteFile` `ApcRoutine` parameter is non-null, which is unsupported"
430429
);
431430
}
432431

433432
if !this.ptr_is_null(apc_ctx)? {
434433
throw_unsup_format!(
435-
"`NtWriteFile` `ApcContext` parameter is not null, which is unsupported"
434+
"`NtWriteFile` `ApcContext` parameter is non-null, which is unsupported"
436435
);
437436
}
438437

@@ -443,7 +442,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
443442
}
444443

445444
if !this.ptr_is_null(key)? {
446-
throw_unsup_format!("`NtWriteFile` `Key` parameter is not null, which is unsupported");
445+
throw_unsup_format!("`NtWriteFile` `Key` parameter is non-null, which is unsupported");
447446
}
448447

449448
let fd = match handle {
@@ -510,17 +509,16 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
510509
n: &OpTy<'tcx>, // ULONG
511510
byte_offset: &OpTy<'tcx>, // PLARGE_INTEGER
512511
key: &OpTy<'tcx>, // PULONG
513-
dest: &MPlaceTy<'tcx>, // NTSTATUS
512+
dest: &MPlaceTy<'tcx>, // return type: NTSTATUS
514513
) -> InterpResult<'tcx, ()> {
515-
// ^ Returns NTSTATUS (u32 on Windows)
516514
let this = self.eval_context_mut();
517515
let handle = this.read_handle(handle, "NtReadFile")?;
518516
let event = this.read_handle(event, "NtReadFile")?;
519517
let apc_routine = this.read_pointer(apc_routine)?;
520518
let apc_ctx = this.read_pointer(apc_ctx)?;
521519
let buf = this.read_pointer(buf)?;
522520
let count = this.read_scalar(n)?.to_u32()?;
523-
let byte_offset = this.read_target_usize(byte_offset)?; // is actually a pointer
521+
let byte_offset = this.read_target_usize(byte_offset)?; // is actually a pointer, but we only support null
524522
let key = this.read_pointer(key)?;
525523
let io_status_block =
526524
this.deref_pointer_as(io_status_block, this.windows_ty_layout("IO_STATUS_BLOCK"))?;
@@ -531,13 +529,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
531529

532530
if !this.ptr_is_null(apc_routine)? {
533531
throw_unsup_format!(
534-
"`NtReadFile` `ApcRoutine` parameter is not null, which is unsupported"
532+
"`NtReadFile` `ApcRoutine` parameter is non-null, which is unsupported"
535533
);
536534
}
537535

538536
if !this.ptr_is_null(apc_ctx)? {
539537
throw_unsup_format!(
540-
"`NtReadFile` `ApcContext` parameter is not null, which is unsupported"
538+
"`NtReadFile` `ApcContext` parameter is non-null, which is unsupported"
541539
);
542540
}
543541

@@ -548,7 +546,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
548546
}
549547

550548
if !this.ptr_is_null(key)? {
551-
throw_unsup_format!("`NtReadFile` `Key` parameter is not null, which is unsupported");
549+
throw_unsup_format!("`NtReadFile` `Key` parameter is non-null, which is unsupported");
552550
}
553551

554552
// See NtWriteFile above for commentary on this

0 commit comments

Comments
 (0)