Skip to content

Commit 084066a

Browse files
cipher.rs: Avoid complex blocks or closures with blocks
Solve "block_in_conditions" error. Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
1 parent af3decc commit 084066a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

psa-crypto/src/operations/cipher.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ fn crypt(
3232

3333
let mut output_length = 0;
3434
let mut output_length_finish = 0;
35-
match (|| {
35+
36+
let status = {
3637
Status::from(unsafe {
3738
psa_crypto_sys::psa_cipher_set_iv(&mut operation, iv.as_ptr(), iv.len())
3839
})
@@ -61,16 +62,16 @@ fn crypt(
6162
.to_result()?;
6263

6364
Ok(())
64-
})() {
65-
Ok(()) => (),
65+
};
66+
67+
match status {
68+
Ok(()) => Ok(output_length + output_length_finish),
6669
Err(x) => {
6770
Status::from(unsafe { psa_crypto_sys::psa_cipher_abort(&mut operation) })
6871
.to_result()?;
69-
return Err(x);
72+
Err(x)
7073
}
7174
}
72-
73-
Ok(output_length + output_length_finish)
7475
}
7576

7677
/// Encrypt a short message with a key

0 commit comments

Comments
 (0)