From 07baf6df44ec3ccd2da43f3c5cb9f5ef30a6b0e8 Mon Sep 17 00:00:00 2001 From: jtmoon79 <815261+jtmoon79@users.noreply.github.com> Date: Sun, 10 Jul 2022 18:01:27 -0700 Subject: [PATCH] fix --blocksz minimum check --blocksz CLI value was checking value too low. Would run but print errors. Now catches low value during argument parsing and exits. --- src/Readers/syslogprocessor.rs | 5 ++++- src/bin/bin.rs | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Readers/syslogprocessor.rs b/src/Readers/syslogprocessor.rs index 0bc50ad8..3c3f1511 100644 --- a/src/Readers/syslogprocessor.rs +++ b/src/Readers/syslogprocessor.rs @@ -171,7 +171,10 @@ impl std::fmt::Debug for SyslogProcessor { impl SyslogProcessor { /// `SyslogProcessor` has it's own miminum requirements for `BlockSz`. /// Necessary for `blockzero_analysis` functions to have chance at success. - pub const BLOCKSZ_MIN: BlockSz = 0x100; + #[cfg(any(debug_assertions,test))] + pub const BLOCKSZ_MIN: BlockSz = 0x2; + #[cfg(not(any(debug_assertions,test)))] + pub const BLOCKSZ_MIN: BlockSz = 0x40; /// allow "streaming" (`drop`ping data in calls to `find_sysline`)? const STREAM_STAGE_DROP: bool = true; /// use LRU caches in underlying components. For development and testing experiments diff --git a/src/bin/bin.rs b/src/bin/bin.rs index 92c3efda..c3b231c2 100644 --- a/src/bin/bin.rs +++ b/src/bin/bin.rs @@ -365,8 +365,9 @@ fn cli_process_blocksz(blockszs: &String) -> std::result::Result { }; } - if ! (BLOCKSZ_MIN <= blocksz_ && blocksz_ <= BLOCKSZ_MAX) { - return Err(format!("--blocksz must be {} ≤ BLOCKSZ ≤ {}, it was {:?}", BLOCKSZ_MIN, BLOCKSZ_MAX, blockszs)); + let max_min = std::cmp::max(BLOCKSZ_MIN, SyslogProcessor::BLOCKSZ_MIN); + if ! (max_min <= blocksz_ && blocksz_ <= BLOCKSZ_MAX) { + return Err(format!("--blocksz must be {} ≤ BLOCKSZ ≤ {}, it was {:?}", max_min, BLOCKSZ_MAX, blockszs)); } Ok(blocksz_)