@@ -46,11 +46,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
46
46
}
47
47
// Linux-only
48
48
"posix_fadvise" => {
49
- let & [ _fd , _offset , _len , _advice ] = check_arg_count ( args) ?;
50
- let _fd = this. read_scalar ( _fd ) ?. to_i32 ( ) ?;
51
- let _offset = this. read_scalar ( _offset ) ?. to_machine_isize ( this) ?;
52
- let _len = this. read_scalar ( _len ) ?. to_machine_isize ( this) ?;
53
- let _advice = this. read_scalar ( _advice ) ?. to_i32 ( ) ?;
49
+ let & [ fd , offset , len , advice ] = check_arg_count ( args) ?;
50
+ this. read_scalar ( fd ) ?. to_i32 ( ) ?;
51
+ this. read_scalar ( offset ) ?. to_machine_isize ( this) ?;
52
+ this. read_scalar ( len ) ?. to_machine_isize ( this) ?;
53
+ this. read_scalar ( advice ) ?. to_i32 ( ) ?;
54
54
// fadvise is only informational, we can ignore it.
55
55
this. write_null ( dest) ?;
56
56
}
@@ -66,8 +66,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
66
66
// Querying system information
67
67
"pthread_attr_getstack" => {
68
68
// We don't support "pthread_attr_setstack", so we just pretend all stacks have the same values here.
69
- let & [ _attr_place , addr_place, size_place] = check_arg_count ( args) ?;
70
- let _attr_place = this. deref_operand ( _attr_place ) ?;
69
+ let & [ attr_place , addr_place, size_place] = check_arg_count ( args) ?;
70
+ this. deref_operand ( attr_place ) ?;
71
71
let addr_place = this. deref_operand ( addr_place) ?;
72
72
let size_place = this. deref_operand ( size_place) ?;
73
73
@@ -102,14 +102,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
102
102
. to_machine_usize ( this) ?;
103
103
104
104
if args. is_empty ( ) {
105
- throw_ub_format ! ( "incorrect number of arguments, needed at least 1" ) ;
105
+ throw_ub_format ! ( "incorrect number of arguments for syscall , needed at least 1" ) ;
106
106
}
107
107
match this. read_scalar ( args[ 0 ] ) ?. to_machine_usize ( this) ? {
108
108
// `libc::syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(), GRND_NONBLOCK)`
109
109
// is called if a `HashMap` is created the regular way (e.g. HashMap<K, V>).
110
110
id if id == sys_getrandom => {
111
111
// The first argument is the syscall id, so skip over it.
112
- getrandom ( this, & args[ 1 ..] , dest) ?;
112
+ let & [ _, ptr, len, flags] = check_arg_count ( args) ?;
113
+ getrandom ( this, ptr, len, flags, dest) ?;
113
114
}
114
115
// `statx` is used by `libstd` to retrieve metadata information on `linux`
115
116
// instead of using `stat`,`lstat` or `fstat` as on `macos`.
@@ -125,13 +126,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
125
126
126
127
// Miscelanneous
127
128
"getrandom" => {
128
- getrandom ( this, args, dest) ?;
129
+ let & [ ptr, len, flags] = check_arg_count ( args) ?;
130
+ getrandom ( this, ptr, len, flags, dest) ?;
129
131
}
130
132
"sched_getaffinity" => {
131
- let & [ _pid , _cpusetsize , _mask ] = check_arg_count ( args) ?;
132
- let _pid = this. read_scalar ( _pid ) ?. to_i32 ( ) ?;
133
- let _cpusetsize = this. read_scalar ( _cpusetsize ) ?. to_machine_usize ( this) ?;
134
- let _mask = this. deref_operand ( _mask ) ?;
133
+ let & [ pid , cpusetsize , mask ] = check_arg_count ( args) ?;
134
+ this. read_scalar ( pid ) ?. to_i32 ( ) ?;
135
+ this. read_scalar ( cpusetsize ) ?. to_machine_usize ( this) ?;
136
+ this. deref_operand ( mask ) ?;
135
137
// FIXME: we just return an error; `num_cpus` then falls back to `sysconf`.
136
138
let einval = this. eval_libc ( "EINVAL" ) ?;
137
139
this. set_last_error ( einval) ?;
@@ -154,16 +156,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
154
156
// Shims the linux `getrandom` syscall.
155
157
fn getrandom < ' tcx > (
156
158
this : & mut MiriEvalContext < ' _ , ' tcx > ,
157
- args : & [ OpTy < ' tcx , Tag > ] ,
159
+ ptr : OpTy < ' tcx , Tag > ,
160
+ len : OpTy < ' tcx , Tag > ,
161
+ flags : OpTy < ' tcx , Tag > ,
158
162
dest : PlaceTy < ' tcx , Tag > ,
159
163
) -> InterpResult < ' tcx > {
160
- let & [ ptr, len, _flags] = check_arg_count ( args) ?;
161
164
let ptr = this. read_scalar ( ptr) ?. not_undef ( ) ?;
162
165
let len = this. read_scalar ( len) ?. to_machine_usize ( this) ?;
163
166
164
167
// The only supported flags are GRND_RANDOM and GRND_NONBLOCK,
165
168
// neither of which have any effect on our current PRNG.
166
- let _flags = this. read_scalar ( _flags ) ?. to_i32 ( ) ?;
169
+ this. read_scalar ( flags ) ?. to_i32 ( ) ?;
167
170
168
171
this. gen_random ( ptr, len) ?;
169
172
this. write_scalar ( Scalar :: from_machine_usize ( len, this) , dest) ?;
0 commit comments