Skip to content

Commit 0720906

Browse files
committed
Removes an assert
1 parent 6be9152 commit 0720906

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

espflash/src/command.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
//! Commands to work with a flasher stub running on a target device
22
3-
use std::{io::Write, mem::size_of, time::Duration};
3+
use std::{
4+
io::{ErrorKind, Write},
5+
mem::size_of,
6+
time::Duration,
7+
};
48

59
use bytemuck::{bytes_of, Pod, Zeroable};
610
use strum::Display;
@@ -448,10 +452,12 @@ fn begin_command<W: Write>(
448452
supports_encryption: bool,
449453
encrypt: bool,
450454
) -> std::io::Result<()> {
451-
assert!(
452-
!(encrypt && !supports_encryption),
453-
"Target does not support encryption, yet encryption is requested"
454-
);
455+
if encrypt && !supports_encryption {
456+
return Err(std::io::Error::new(
457+
ErrorKind::InvalidInput,
458+
"Target does not support encryption, yet encryption is requested",
459+
));
460+
}
455461

456462
#[derive(Zeroable, Pod, Copy, Clone, Debug)]
457463
#[repr(C)]

0 commit comments

Comments
 (0)