Skip to content

Commit

Permalink
Merge pull request #5626 from stacks-network/fix/clippy-ci-stacks-lib…
Browse files Browse the repository at this point in the history
…-int-plus-one

Fix int_plus_one warnings
  • Loading branch information
obycode authored Feb 8, 2025
2 parents 851ada6 + 2ca368e commit 4dadde0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions stackslib/src/chainstate/nakamoto/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ impl NakamotoBlockBuilder {
))
})?;

if naka_tip_header.anchored_header.height() + 1
<= naka_tip_tenure_start_header.anchored_header.height()
if naka_tip_header.anchored_header.height()
< naka_tip_tenure_start_header.anchored_header.height()
{
return Err(Error::InvalidStacksBlock(
"Nakamoto tip is lower than its tenure-start block".into(),
Expand Down
9 changes: 2 additions & 7 deletions stackslib/src/chainstate/stacks/index/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,8 @@ impl Trie {
// append the new leaf and the end of the file.
let new_leaf_disk_ptr = storage.last_ptr()?;
let new_leaf_chr = cursor.path[cursor.tell()]; // NOTE: this is safe because !cursor.eop()
let new_leaf_path = cursor.path[(if cursor.tell() + 1 <= cursor.path.len() {
cursor.tell() + 1
} else {
cursor.path.len()
})..]
.to_vec();
new_leaf_data.path = new_leaf_path;
new_leaf_data.path =
cursor.path[std::cmp::min(cursor.tell() + 1, cursor.path.len())..].to_vec();
let new_leaf_hash = get_leaf_hash(new_leaf_data);

// put new leaf at the end of this Trie
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2297,7 +2297,7 @@ fn test_build_anchored_blocks_invalid() {

eprintln!("\n\nat resume parent tenure:\nlast_parent: {:?}\nlast_parent_tip: {:?}\n\n", &last_parent, &last_parent_tip);
}
else if tenure_id >= bad_block_tenure + 1 {
else if tenure_id > bad_block_tenure {
last_parent = None;
last_parent_tip = None;
}
Expand Down
4 changes: 2 additions & 2 deletions stackslib/src/net/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl RelayerStats {
let mut to_remove = vec![];
for (ts, old_addr) in self.relay_updates.iter() {
self.relay_stats.remove(old_addr);
if self.relay_stats.len() <= MAX_RELAYER_STATS - 1 {
if self.relay_stats.len() < MAX_RELAYER_STATS {
break;
}
to_remove.push(*ts);
Expand Down Expand Up @@ -342,7 +342,7 @@ impl RelayerStats {
let mut to_remove = vec![];
for (ts, old_nk) in self.recent_updates.iter() {
self.recent_messages.remove(old_nk);
if self.recent_messages.len() <= MAX_RELAYER_STATS - 1 {
if self.recent_messages.len() < MAX_RELAYER_STATS {
break;
}
to_remove.push(*ts);
Expand Down

0 comments on commit 4dadde0

Please sign in to comment.