Skip to content

Commit

Permalink
Fix cfg flags, silence warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dani-garcia committed Sep 24, 2024
1 parent bcd712f commit 38343d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions crates/bitwarden-crypto/src/service/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub(crate) struct RustCryptoServiceContext<
pub(crate) local_asymmetric_keys: Box<dyn KeyStore<AsymmKeyRef>>,
}

#[allow(unused)]
impl<'a, SymmKeyRef: SymmetricKeyRef, AsymmKeyRef: AsymmetricKeyRef>
RustCryptoServiceContext<'a, SymmKeyRef, AsymmKeyRef>
{
Expand Down
9 changes: 5 additions & 4 deletions crates/bitwarden-crypto/src/service/key_store/rust_impl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::mem::MaybeUninit;

use super::{
util::{KeyData, SliceKeyStore},
KeyRef,
Expand All @@ -17,8 +15,10 @@ pub(crate) struct RustImplKeyData<Key: KeyRef> {

impl<Key: KeyRef> Drop for RustImplKeyData<Key> {
fn drop(&mut self) {
#[cfg(any(not(target_arch = "wasm32"), not(feature = "no-memory-hardening")))]
#[cfg(all(not(target_arch = "wasm32"), not(feature = "no-memory-hardening")))]
{
use std::mem::MaybeUninit;

let entry_size = std::mem::size_of::<Option<(Key, Key::KeyValue)>>();
unsafe {
memsec::munlock(
Expand Down Expand Up @@ -47,9 +47,10 @@ impl<Key: KeyRef> KeyData<Key> for RustImplKeyData<Key> {
}

Check warning on line 47 in crates/bitwarden-crypto/src/service/key_store/rust_impl.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-crypto/src/service/key_store/rust_impl.rs#L45-L47

Added lines #L45 - L47 were not covered by tests

fn with_capacity(capacity: usize) -> Self {
#[allow(unused_mut)]
let mut data: Box<_> = std::iter::repeat_with(|| None).take(capacity).collect();

#[cfg(any(not(target_arch = "wasm32"), not(feature = "no-memory-hardening")))]
#[cfg(all(not(target_arch = "wasm32"), not(feature = "no-memory-hardening")))]
{
let entry_size = std::mem::size_of::<Option<(Key, Key::KeyValue)>>();
unsafe {
Expand Down

0 comments on commit 38343d2

Please sign in to comment.