From e584aa0e784681f6331e5a8f6a0beb16be4bf731 Mon Sep 17 00:00:00 2001 From: Matt Keeter Date: Mon, 30 Oct 2023 15:11:33 -0400 Subject: [PATCH] Add assertion --- downstairs/src/extent_inner_raw.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/downstairs/src/extent_inner_raw.rs b/downstairs/src/extent_inner_raw.rs index eeb0d28a0..b8459d8b1 100644 --- a/downstairs/src/extent_inner_raw.rs +++ b/downstairs/src/extent_inner_raw.rs @@ -1317,6 +1317,10 @@ impl RawLayout { /// Write out the active context array and metadata section of the file /// /// This is done in a single write, so it should be atomic. + /// + /// # Panics + /// `active_context.len()` must match `self.block_count()`, and the function + /// will panic otherwise. fn write_active_context_and_metadata( &self, file: &File, @@ -1325,6 +1329,8 @@ impl RawLayout { flush_number: u64, gen_number: u64, ) -> Result<(), CrucibleError> { + assert_eq!(active_context.len(), self.block_count() as usize); + // Serialize bitpacked active slot values let mut buf = self.buf.take(); buf.clear();