@@ -15,19 +15,19 @@ pub fn futex<'tcx>(
1515 // may or may not be left out from the `syscall()` call.
1616 // Therefore we don't use `check_arg_count` here, but only check for the
1717 // number of arguments to fall within a range.
18- if args . len ( ) < 3 {
18+ let [ addr , op , val , .. ] = args else {
1919 throw_ub_format ! (
2020 "incorrect number of arguments for `futex` syscall: got {}, expected at least 3" ,
2121 args. len( )
2222 ) ;
23- }
23+ } ;
2424
2525 // The first three arguments (after the syscall number itself) are the same to all futex operations:
2626 // (int *addr, int op, int val).
2727 // 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 ( ) ?;
3131
3232 // This is a vararg function so we have to bring our own type for this pointer.
3333 let addr = this. ptr_to_mplace ( addr, this. machine . layouts . i32 ) ;
@@ -55,15 +55,15 @@ pub fn futex<'tcx>(
5555 let wait_bitset = op & !futex_realtime == futex_wait_bitset;
5656
5757 let bitset = if wait_bitset {
58- if args . len ( ) < 6 {
58+ let [ _ , _ , _ , timeout , uaddr2 , bitset , .. ] = args else {
5959 throw_ub_format ! (
6060 "incorrect number of arguments for `futex` syscall with `op=FUTEX_WAIT_BITSET`: got {}, expected at least 6" ,
6161 args. len( )
6262 ) ;
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 ( ) ?
6767 } else {
6868 if args. len ( ) < 4 {
6969 throw_ub_format ! (
@@ -183,15 +183,15 @@ pub fn futex<'tcx>(
183183 // Same as FUTEX_WAKE, but allows you to specify a bitset to select which threads to wake up.
184184 op if op == futex_wake || op == futex_wake_bitset => {
185185 let bitset = if op == futex_wake_bitset {
186- if args . len ( ) < 6 {
186+ let [ _ , _ , _ , timeout , uaddr2 , bitset , .. ] = args else {
187187 throw_ub_format ! (
188188 "incorrect number of arguments for `futex` syscall with `op=FUTEX_WAKE_BITSET`: got {}, expected at least 6" ,
189189 args. len( )
190190 ) ;
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 ( ) ?
195195 } else {
196196 u32:: MAX
197197 } ;
0 commit comments