Skip to content

Commit

Permalink
Use let = if; instead of let; if.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Apr 6, 2022
1 parent 5581e33 commit 03417de
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/shims/posix/linux/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,23 @@ pub fn futex<'tcx>(
op if op & !futex_realtime == futex_wait || op & !futex_realtime == futex_wait_bitset => {
let wait_bitset = op & !futex_realtime == futex_wait_bitset;

let bitset;

if wait_bitset {
let bitset = if wait_bitset {
if args.len() != 7 {
throw_ub_format!(
"incorrect number of arguments for `futex` syscall with `op=FUTEX_WAIT_BITSET`: got {}, expected 7",
args.len()
);
}
bitset = this.read_scalar(&args[6])?.to_u32()?;
this.read_scalar(&args[6])?.to_u32()?
} else {
if args.len() < 5 {
throw_ub_format!(
"incorrect number of arguments for `futex` syscall with `op=FUTEX_WAIT`: got {}, expected at least 5",
args.len()
);
}
bitset = u32::MAX;
}
u32::MAX
};

if bitset == 0 {
let einval = this.eval_libc("EINVAL")?;
Expand Down Expand Up @@ -182,18 +180,17 @@ pub fn futex<'tcx>(
// FUTEX_WAKE_BITSET: (int *addr, int op = FUTEX_WAKE, int val, const timespect *_unused, int *_unused, unsigned int bitset)
// Same as FUTEX_WAKE, but allows you to specify a bitset to select which threads to wake up.
op if op == futex_wake || op == futex_wake_bitset => {
let bitset;
if op == futex_wake_bitset {
let bitset = if op == futex_wake_bitset {
if args.len() != 7 {
throw_ub_format!(
"incorrect number of arguments for `futex` syscall with `op=FUTEX_WAKE_BITSET`: got {}, expected 7",
args.len()
);
}
bitset = this.read_scalar(&args[6])?.to_u32()?;
this.read_scalar(&args[6])?.to_u32()?
} else {
bitset = u32::MAX;
}
u32::MAX
};
if bitset == 0 {
let einval = this.eval_libc("EINVAL")?;
this.set_last_error(einval)?;
Expand Down

0 comments on commit 03417de

Please sign in to comment.