From 7ea812fd54f04070d16a5f69ff3b034814bf72b8 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 3 Jul 2025 17:47:34 +0200 Subject: [PATCH] nanosleep: fix argument name and add a missing argument read --- src/tools/miri/src/shims/time.rs | 11 ++++------- src/tools/miri/src/shims/unix/foreign_items.rs | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/tools/miri/src/shims/time.rs b/src/tools/miri/src/shims/time.rs index 28f4ca5bb1b7..2fc42c13edd3 100644 --- a/src/tools/miri/src/shims/time.rs +++ b/src/tools/miri/src/shims/time.rs @@ -330,18 +330,15 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { interp_ok(Scalar::from_i32(0)) // KERN_SUCCESS } - fn nanosleep( - &mut self, - req_op: &OpTy<'tcx>, - _rem: &OpTy<'tcx>, // Signal handlers are not supported, so rem will never be written to. - ) -> InterpResult<'tcx, Scalar> { + fn nanosleep(&mut self, duration: &OpTy<'tcx>, rem: &OpTy<'tcx>) -> InterpResult<'tcx, Scalar> { let this = self.eval_context_mut(); this.assert_target_os_is_unix("nanosleep"); - let req = this.deref_pointer_as(req_op, this.libc_ty_layout("timespec"))?; + let duration = this.deref_pointer_as(duration, this.libc_ty_layout("timespec"))?; + let _rem = this.read_pointer(rem)?; // Signal handlers are not supported, so rem will never be written to. - let duration = match this.read_timespec(&req)? { + let duration = match this.read_timespec(&duration)? { Some(duration) => duration, None => { return this.set_last_error_and_return_i32(LibcError("EINVAL")); diff --git a/src/tools/miri/src/shims/unix/foreign_items.rs b/src/tools/miri/src/shims/unix/foreign_items.rs index b3c58397a02b..438a9b420be6 100644 --- a/src/tools/miri/src/shims/unix/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/foreign_items.rs @@ -963,8 +963,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_null(dest)?; } "nanosleep" => { - let [req, rem] = this.check_shim(abi, CanonAbi::C, link_name, args)?; - let result = this.nanosleep(req, rem)?; + let [duration, rem] = this.check_shim(abi, CanonAbi::C, link_name, args)?; + let result = this.nanosleep(duration, rem)?; this.write_scalar(result, dest)?; } "sched_getaffinity" => {