Skip to content

Commit

Permalink
fix --blocksz minimum check
Browse files Browse the repository at this point in the history
--blocksz CLI value was checking value too low. Would run but print
errors. Now catches low value during argument parsing and exits.
  • Loading branch information
jtmoon79 committed Jul 11, 2022
1 parent e65726d commit 07baf6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Readers/syslogprocessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/bin/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,9 @@ fn cli_process_blocksz(blockszs: &String) -> std::result::Result<u64, String> {
};
}

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_)
Expand Down

0 comments on commit 07baf6d

Please sign in to comment.