Skip to content

Commit 03417de

Browse files
committed
Use let = if; instead of let; if.
1 parent 5581e33 commit 03417de

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/shims/posix/linux/sync.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,23 @@ pub fn futex<'tcx>(
5555
op if op & !futex_realtime == futex_wait || op & !futex_realtime == futex_wait_bitset => {
5656
let wait_bitset = op & !futex_realtime == futex_wait_bitset;
5757

58-
let bitset;
59-
60-
if wait_bitset {
58+
let bitset = if wait_bitset {
6159
if args.len() != 7 {
6260
throw_ub_format!(
6361
"incorrect number of arguments for `futex` syscall with `op=FUTEX_WAIT_BITSET`: got {}, expected 7",
6462
args.len()
6563
);
6664
}
67-
bitset = this.read_scalar(&args[6])?.to_u32()?;
65+
this.read_scalar(&args[6])?.to_u32()?
6866
} else {
6967
if args.len() < 5 {
7068
throw_ub_format!(
7169
"incorrect number of arguments for `futex` syscall with `op=FUTEX_WAIT`: got {}, expected at least 5",
7270
args.len()
7371
);
7472
}
75-
bitset = u32::MAX;
76-
}
73+
u32::MAX
74+
};
7775

7876
if bitset == 0 {
7977
let einval = this.eval_libc("EINVAL")?;
@@ -182,18 +180,17 @@ pub fn futex<'tcx>(
182180
// FUTEX_WAKE_BITSET: (int *addr, int op = FUTEX_WAKE, int val, const timespect *_unused, int *_unused, unsigned int bitset)
183181
// Same as FUTEX_WAKE, but allows you to specify a bitset to select which threads to wake up.
184182
op if op == futex_wake || op == futex_wake_bitset => {
185-
let bitset;
186-
if op == futex_wake_bitset {
183+
let bitset = if op == futex_wake_bitset {
187184
if args.len() != 7 {
188185
throw_ub_format!(
189186
"incorrect number of arguments for `futex` syscall with `op=FUTEX_WAKE_BITSET`: got {}, expected 7",
190187
args.len()
191188
);
192189
}
193-
bitset = this.read_scalar(&args[6])?.to_u32()?;
190+
this.read_scalar(&args[6])?.to_u32()?
194191
} else {
195-
bitset = u32::MAX;
196-
}
192+
u32::MAX
193+
};
197194
if bitset == 0 {
198195
let einval = this.eval_libc("EINVAL")?;
199196
this.set_last_error(einval)?;

0 commit comments

Comments
 (0)