Skip to content

Commit 8e10b25

Browse files
author
valdok
committed
build fix (Clippy)
1 parent 60b7d74 commit 8e10b25

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

cosmwasm/enclaves/shared/utils/src/storage.rs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,12 @@ pub fn unseal_file_from_2_17(
208208

209209
let p_iv: [u8; 12] = [0; 12];
210210

211-
if let Err(e) = cur_key_mac.decrypt_once(
211+
cur_key_mac.decrypt_once(
212212
std::ptr::addr_of!((*p_md).encr) as *const u8,
213213
mem::size_of::<FileMdEncrypted>() as u32,
214214
std::ptr::addr_of!(md_decr) as *mut uint8_t,
215215
&p_iv,
216-
) {
217-
warn!("decrypt file md failed");
218-
return Err(e);
219-
}
216+
)?;
220217

221218
if should_check_fname {
222219
let raw_path = s_path.as_bytes();
@@ -277,33 +274,27 @@ pub fn unseal_file_from_2_17(
277274
ptr::copy_nonoverlapping(md_decr.data.as_ptr(), bytes.as_mut_ptr(), offs_dst);
278275

279276
// Decode mht node
280-
let p_mht_node = bytes_src
281-
.as_mut_ptr()
282-
.offset(mem::size_of::<FileMd>() as isize)
283-
as *mut FileMhtNode;
277+
let p_mht_node =
278+
bytes_src.as_mut_ptr().add(mem::size_of::<FileMd>()) as *mut FileMhtNode;
284279

285-
if let Err(e) = md_decr.root_mht.decrypt_once(
280+
md_decr.root_mht.decrypt_once(
286281
p_mht_node as *const u8,
287282
mem::size_of::<FileMhtNode>() as u32,
288283
p_mht_node as *mut uint8_t,
289284
&p_iv,
290-
) {
291-
return Err(e);
292-
}
285+
)?;
293286

294287
let mut offs_src = mem::size_of::<FileMd>() + node_size;
295288

296289
for i_node in 0..num_nodes {
297290
let keys = &(*p_mht_node).data[i_node];
298291

299-
if let Err(e) = keys.decrypt_once(
300-
bytes_src.as_ptr().offset(offs_src as isize),
292+
keys.decrypt_once(
293+
bytes_src.as_ptr().add(offs_src),
301294
node_size as u32,
302-
bytes.as_mut_ptr().offset(offs_dst as isize),
295+
bytes.as_mut_ptr().add(offs_dst),
303296
&p_iv,
304-
) {
305-
return Err(e);
306-
}
297+
)?;
307298

308299
offs_src += node_size;
309300
offs_dst += node_size;

0 commit comments

Comments
 (0)