From 892f950cc13247a6b772f304dedc49b45c12e310 Mon Sep 17 00:00:00 2001
From: Julien Cretin <cretin@google.com>
Date: Wed, 29 Apr 2020 12:59:22 +0200
Subject: [PATCH] Add missing cfg

---
 src/ctap/storage.rs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/ctap/storage.rs b/src/ctap/storage.rs
index 3d0c4d2..879c1e7 100644
--- a/src/ctap/storage.rs
+++ b/src/ctap/storage.rs
@@ -143,6 +143,7 @@ const PAGE_SIZE: usize = 0x1000;
 // 0x30000-0x3ffff: Padding
 // 0x40000-0xbffff: App
 // 0xc0000-0xfffff: Store
+#[cfg(not(any(test, feature = "ram_storage")))]
 const STORE_ADDR: usize = 0xC0000;
 const STORE_SIZE_LIMIT: usize = 0x40000;
 const STORE_SIZE: usize = NUM_PAGES * PAGE_SIZE;
@@ -154,6 +155,8 @@ impl PersistentStore {
     ///
     /// This should be at most one instance of persistent store per program lifetime.
     pub fn new(rng: &mut impl Rng256) -> PersistentStore {
+        // This should ideally be a compile-time assert, but Rust doesn't have native support.
+        assert!(STORE_SIZE <= STORE_SIZE_LIMIT);
         #[cfg(not(any(test, feature = "ram_storage")))]
         let storage = PersistentStore::new_prod_storage();
         #[cfg(any(test, feature = "ram_storage"))]
@@ -167,8 +170,6 @@ impl PersistentStore {
 
     #[cfg(not(any(test, feature = "ram_storage")))]
     fn new_prod_storage() -> Storage {
-        // This should ideally be a compile-time assert, but Rust doesn't have native support.
-        assert!(STORE_SIZE <= STORE_SIZE_LIMIT);
         let store = unsafe {
             // Safety: The store cannot alias because this function is called only once.
             core::slice::from_raw_parts_mut(STORE_ADDR as *mut u8, STORE_SIZE)
-- 
GitLab