@@ -15,19 +15,19 @@ pub fn futex<'tcx>(
15
15
// may or may not be left out from the `syscall()` call.
16
16
// Therefore we don't use `check_arg_count` here, but only check for the
17
17
// number of arguments to fall within a range.
18
- if args . len ( ) < 3 {
18
+ let [ addr , op , val , .. ] = args else {
19
19
throw_ub_format ! (
20
20
"incorrect number of arguments for `futex` syscall: got {}, expected at least 3" ,
21
21
args. len( )
22
22
) ;
23
- }
23
+ } ;
24
24
25
25
// The first three arguments (after the syscall number itself) are the same to all futex operations:
26
26
// (int *addr, int op, int val).
27
27
// We checked above that these definitely exist.
28
- let addr = this. read_pointer ( & args [ 0 ] ) ?;
29
- let op = this. read_scalar ( & args [ 1 ] ) ?. to_i32 ( ) ?;
30
- let val = this. read_scalar ( & args [ 2 ] ) ?. to_i32 ( ) ?;
28
+ let addr = this. read_pointer ( addr ) ?;
29
+ let op = this. read_scalar ( op ) ?. to_i32 ( ) ?;
30
+ let val = this. read_scalar ( val ) ?. to_i32 ( ) ?;
31
31
32
32
// This is a vararg function so we have to bring our own type for this pointer.
33
33
let addr = this. ptr_to_mplace ( addr, this. machine . layouts . i32 ) ;
@@ -55,15 +55,15 @@ pub fn futex<'tcx>(
55
55
let wait_bitset = op & !futex_realtime == futex_wait_bitset;
56
56
57
57
let bitset = if wait_bitset {
58
- if args . len ( ) < 6 {
58
+ let [ _ , _ , _ , timeout , uaddr2 , bitset , .. ] = args else {
59
59
throw_ub_format ! (
60
60
"incorrect number of arguments for `futex` syscall with `op=FUTEX_WAIT_BITSET`: got {}, expected at least 6" ,
61
61
args. len( )
62
62
) ;
63
- }
64
- let _timeout = this. read_pointer ( & args [ 3 ] ) ?;
65
- let _uaddr2 = this. read_pointer ( & args [ 4 ] ) ?;
66
- this. read_scalar ( & args [ 5 ] ) ?. to_u32 ( ) ?
63
+ } ;
64
+ let _timeout = this. read_pointer ( timeout ) ?;
65
+ let _uaddr2 = this. read_pointer ( uaddr2 ) ?;
66
+ this. read_scalar ( bitset ) ?. to_u32 ( ) ?
67
67
} else {
68
68
if args. len ( ) < 4 {
69
69
throw_ub_format ! (
@@ -183,15 +183,15 @@ pub fn futex<'tcx>(
183
183
// Same as FUTEX_WAKE, but allows you to specify a bitset to select which threads to wake up.
184
184
op if op == futex_wake || op == futex_wake_bitset => {
185
185
let bitset = if op == futex_wake_bitset {
186
- if args . len ( ) < 6 {
186
+ let [ _ , _ , _ , timeout , uaddr2 , bitset , .. ] = args else {
187
187
throw_ub_format ! (
188
188
"incorrect number of arguments for `futex` syscall with `op=FUTEX_WAKE_BITSET`: got {}, expected at least 6" ,
189
189
args. len( )
190
190
) ;
191
- }
192
- let _timeout = this. read_pointer ( & args [ 3 ] ) ?;
193
- let _uaddr2 = this. read_pointer ( & args [ 4 ] ) ?;
194
- this. read_scalar ( & args [ 5 ] ) ?. to_u32 ( ) ?
191
+ } ;
192
+ let _timeout = this. read_pointer ( timeout ) ?;
193
+ let _uaddr2 = this. read_pointer ( uaddr2 ) ?;
194
+ this. read_scalar ( bitset ) ?. to_u32 ( ) ?
195
195
} else {
196
196
u32:: MAX
197
197
} ;
0 commit comments