Closed
Description
Unix shims return -1
and set the thread-local "last error" variable to indicate an error occurred. With #3923 and #3929, Miri has some nice helpers to help with that, but they are not being used everywhere yet. So this is about refactoring the existing code to use the new helpers.
To help, start by grepping for -1
and for this.eval_libc("E
in the src/shims/unix
folder. You will find a few patterns:
let efault = this.eval_libc("EFAULT");
this.set_last_error(efault)?;
this.write_int(-1, dest)?;
should become this.set_last_error_and_return(LibcError("EFAULT"), dest)?;
.
this.set_last_error(ErrorKind::PermissionDenied)?;
return Ok(Scalar::from_i32(-1));
should become return this.set_last_error_and_return_i32(ErrorKind::PermissionDenied);
.
Feel free to ask if you encounter other patterns you are unsure about. It's also okay for the first PR to only cover parts of this and leave the harder cases for a second round.