Skip to content

Commit

Permalink
Cleanup devel features, and describe them
Browse files Browse the repository at this point in the history
  • Loading branch information
szszszsz committed Jan 24, 2023
1 parent b305cc9 commit 98c8b01
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ pretty_env_logger = "0.4.0"

[features]
default = ["apdu-dispatch"]
devel = ["apdu-dispatch", "log-all", "delog/std-log"]
devel = ["apdu-dispatch", "log-all", "delog/std-log", "devel-counters", "devel-ctaphid-bug"]

# Count accesses to the read-only and read-write persistence storage
devel-counters = []

# Account ctaphid bug about 3072 buffer size. To be removed once fixed.
devel-ctaphid-bug = []

# Allow to use application over CTAPHID interface
ctaphid = ["ctaphid-dispatch", "usbd-ctaphid"]
Expand Down
4 changes: 3 additions & 1 deletion src/authenticator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,10 @@ where
reply.push((credential.label.len() + 1) as u8)?;
reply.push(oath::combine(credential.kind, credential.algorithm))?;
reply.extend_from_slice(&credential.label).map_err(|_| 0)?;
#[cfg(feature = "devel")]
#[cfg(feature = "devel-ctaphid-bug")]
if reply.len() > 3072 {
// Finish early due to the usbd-ctaphid bug, which panics on bigger buffers than this
// FIXME Remove once fixed
return Err(1);
}
Ok(())
Expand Down
10 changes: 6 additions & 4 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ pub struct State {
// temporary "state", to be removed again
// pub hack: Hack,
// trussed: RefCell<Trussed<S>>,
#[cfg(feature = "devel")]
// Count read-write access to the persistence storage. Development only.
#[cfg(feature = "devel-counters")]
counter_read_write: u32,
#[cfg(feature = "devel")]
// Count read-only access to the persistence storage. Development only.
#[cfg(feature = "devel-counters")]
counter_read_only: u32,
}

Expand Down Expand Up @@ -173,7 +175,7 @@ impl State {
{
let mut state: Persistent = Self::get_persistent_or_default(trussed);

#[cfg(feature = "devel")]
#[cfg(feature = "devel-counters")]
{
self.counter_read_write += 1;
debug_now!("Getting the state RW {}", self.counter_read_write);
Expand Down Expand Up @@ -202,7 +204,7 @@ impl State {
{
let state: Persistent = Self::get_persistent_or_default(trussed);

#[cfg(feature = "devel")]
#[cfg(feature = "devel-counters")]
{
self.counter_read_only += 1;
debug_now!("Getting the state RO {}", self.counter_read_only);
Expand Down

0 comments on commit 98c8b01

Please sign in to comment.