Skip to content

Commit eff09d1

Browse files
Fix clippy warnings
1 parent a38e2ce commit eff09d1

File tree

7 files changed

+34
-32
lines changed

7 files changed

+34
-32
lines changed

src/chunked/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ impl<'a, LenT: heapless::LenType, S: heapless_bytes::BytesStorage + ?Sized>
4040

4141
impl<'a, LenT: heapless::LenType> AsMut<[u8]> for HeaplessBuffer<'a, LenT> {
4242
fn as_mut(&mut self) -> &mut [u8] {
43-
&mut self.0
43+
self.0
4444
}
4545
}
4646

4747
impl<'a, LenT: heapless::LenType> AsRef<[u8]> for HeaplessBuffer<'a, LenT> {
4848
fn as_ref(&self) -> &[u8] {
49-
&self.0
49+
self.0
5050
}
5151
}
5252

src/hkdf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn extract<S: Store>(
6565
.as_ref()
6666
.map(|s| get_mat(s, keystore))
6767
.transpose()?;
68-
let salt_ref = salt.as_deref().map(|d| &*d);
68+
let salt_ref = salt.as_deref();
6969
let (prk, _) = Hkdf::<Sha256>::extract(salt_ref, &ikm);
7070
assert_eq!(prk.len(), 256 / 8);
7171
let key_id = keystore.store_key(

src/hpke.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ trait Aead:
122122
TagSize = <ChaCha20Poly1305 as AeadCore>::TagSize,
123123
>
124124
{
125+
// The AEAD_ID is the last 2 bytes of the X25519_HKDF_SHA256_SELF_HPKE_SUITE_ID
126+
#[cfg_attr(not(test), allow(unused))]
125127
const AEAD_ID: u16;
126128
const X25519_HKDF_SHA256_SELF_HPKE_SUITE_ID: &'static [u8];
127129
}

tests/chunked.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn filesystem() {
5959
.metadata
6060
.is_none(),);
6161

62-
let data = Bytes::try_from(b"test data").unwrap();
62+
let data = Bytes::from(b"test data");
6363
syscall!(client.write_file(
6464
Location::Internal,
6565
PathBuf::from(path!("test_file")),
@@ -82,9 +82,9 @@ fn filesystem() {
8282
assert!(empty_data.data.is_empty());
8383
assert_eq!(empty_data.len, data.len());
8484

85-
let large_data = Bytes::try_from(&[0; 1024]).unwrap();
86-
let large_data2 = Bytes::try_from(&[1; 1024]).unwrap();
87-
let more_data = Bytes::try_from(&[2; 42]).unwrap();
85+
let large_data = Bytes::from(&[0; 1024]);
86+
let large_data2 = Bytes::from(&[1; 1024]);
87+
let more_data = Bytes::from(&[2; 42]);
8888
// ======== CHUNKED WRITES ========
8989
syscall!(client.start_chunked_write(
9090
Location::Internal,

tests/encrypted-chunked.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ fn encrypted_filesystem() {
8787
.is_none(),
8888
);
8989

90-
let large_data = Bytes::try_from(&[0; 1024]).unwrap();
91-
let large_data2 = Bytes::try_from(&[1; 1024]).unwrap();
92-
let more_data = Bytes::try_from(&[2; 42]).unwrap();
90+
let large_data = Bytes::from(&[0; 1024]);
91+
let large_data2 = Bytes::from(&[1; 1024]);
92+
let more_data = Bytes::from(&[2; 42]);
9393
// ======== CHUNKED WRITES ========
9494
syscall!(client.start_encrypted_chunked_write(
9595
Location::Internal,

tests/hpke.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ fn hpke_message() {
4141
let public_key =
4242
syscall!(client.derive_x255_public_key(secret_key, Location::Volatile)).key;
4343

44-
let pl = Bytes::try_from(b"Plaintext").unwrap();
45-
let aad = Bytes::try_from(b"AAD").unwrap();
46-
let info = Bytes::try_from(b"INFO").unwrap();
44+
let pl = Bytes::from(b"Plaintext");
45+
let aad = Bytes::from(b"AAD");
46+
let info = Bytes::from(b"INFO");
4747
let seal = syscall!(client.hpke_seal(
4848
public_key,
4949
pl.clone(),
@@ -69,8 +69,8 @@ fn hpke_wrap_key() {
6969

7070
let key_to_wrap = syscall!(client.generate_secret_key(32, Location::Volatile)).key;
7171

72-
let aad = Bytes::try_from(b"AAD").unwrap();
73-
let info = Bytes::try_from(b"INFO").unwrap();
72+
let aad = Bytes::from(b"AAD");
73+
let info = Bytes::from(b"INFO");
7474
let seal =
7575
syscall!(client.hpke_seal_key(public_key, key_to_wrap, aad.clone(), info.clone()));
7676

@@ -96,8 +96,8 @@ fn hpke_wrap_key_to_file() {
9696
let key_to_wrap = syscall!(client.generate_secret_key(32, Location::Volatile)).key;
9797

9898
let path = path!("WRAPPED_KEY");
99-
let aad = Bytes::try_from(b"AAD").unwrap();
100-
let info = Bytes::try_from(b"INFO").unwrap();
99+
let aad = Bytes::from(b"AAD");
100+
let info = Bytes::from(b"INFO");
101101
syscall!(client.hpke_seal_key_to_file(
102102
path.into(),
103103
Location::Volatile,

tests/manage.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,56 +27,56 @@ fn device_factory_reset() {
2727
syscall!(client1.write_file(
2828
Location::Internal,
2929
path!("to_save_internal").into(),
30-
Bytes::try_from(b"data").unwrap(),
30+
Bytes::from(b"data"),
3131
None,
3232
));
3333
syscall!(client1.write_file(
3434
Location::External,
3535
path!("to_save_external").into(),
36-
Bytes::try_from(b"data").unwrap(),
36+
Bytes::from(b"data"),
3737
None,
3838
));
3939
syscall!(client1.write_file(
4040
Location::Volatile,
4141
path!("to_save_volatile").into(),
42-
Bytes::try_from(b"data").unwrap(),
42+
Bytes::from(b"data"),
4343
None
4444
));
4545
syscall!(client1.write_file(
4646
Location::Internal,
4747
path!("to_delete_internal").into(),
48-
Bytes::try_from(b"data").unwrap(),
48+
Bytes::from(b"data"),
4949
None,
5050
));
5151
syscall!(client1.write_file(
5252
Location::External,
5353
path!("to_delete_external").into(),
54-
Bytes::try_from(b"data").unwrap(),
54+
Bytes::from(b"data"),
5555
None,
5656
));
5757
syscall!(client1.write_file(
5858
Location::Volatile,
5959
path!("to_delete_volatile").into(),
60-
Bytes::try_from(b"data").unwrap(),
60+
Bytes::from(b"data"),
6161
None
6262
));
6363

6464
syscall!(client2.write_file(
6565
Location::Internal,
6666
path!("to_delete_internal").into(),
67-
Bytes::try_from(b"data").unwrap(),
67+
Bytes::from(b"data"),
6868
None,
6969
));
7070
syscall!(client2.write_file(
7171
Location::External,
7272
path!("to_delete_external").into(),
73-
Bytes::try_from(b"data").unwrap(),
73+
Bytes::from(b"data"),
7474
None,
7575
));
7676
syscall!(client2.write_file(
7777
Location::Volatile,
7878
path!("to_delete_volatile").into(),
79-
Bytes::try_from(b"data").unwrap(),
79+
Bytes::from(b"data"),
8080
None
8181
));
8282

@@ -140,37 +140,37 @@ fn client_factory_reset() {
140140
syscall!(client1.write_file(
141141
Location::Internal,
142142
path!("to_save_internal").into(),
143-
Bytes::try_from(b"data").unwrap(),
143+
Bytes::from(b"data"),
144144
None,
145145
));
146146
syscall!(client1.write_file(
147147
Location::External,
148148
path!("to_save_external").into(),
149-
Bytes::try_from(b"data").unwrap(),
149+
Bytes::from(b"data"),
150150
None,
151151
));
152152
syscall!(client1.write_file(
153153
Location::Volatile,
154154
path!("to_save_volatile").into(),
155-
Bytes::try_from(b"data").unwrap(),
155+
Bytes::from(b"data"),
156156
None
157157
));
158158
syscall!(client2.write_file(
159159
Location::Internal,
160160
path!("to_delete_internal").into(),
161-
Bytes::try_from(b"data").unwrap(),
161+
Bytes::from(b"data"),
162162
None,
163163
));
164164
syscall!(client2.write_file(
165165
Location::External,
166166
path!("to_delete_external").into(),
167-
Bytes::try_from(b"data").unwrap(),
167+
Bytes::from(b"data"),
168168
None,
169169
));
170170
syscall!(client2.write_file(
171171
Location::Volatile,
172172
path!("to_delete_volatile").into(),
173-
Bytes::try_from(b"data").unwrap(),
173+
Bytes::from(b"data"),
174174
None
175175
));
176176

0 commit comments

Comments
 (0)