Skip to content

Commit 4dadde0

Browse files
authored
Merge pull request #5626 from stacks-network/fix/clippy-ci-stacks-lib-int-plus-one
Fix int_plus_one warnings
2 parents 851ada6 + 2ca368e commit 4dadde0

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

stackslib/src/chainstate/nakamoto/shadow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,8 @@ impl NakamotoBlockBuilder {
631631
))
632632
})?;
633633

634-
if naka_tip_header.anchored_header.height() + 1
635-
<= naka_tip_tenure_start_header.anchored_header.height()
634+
if naka_tip_header.anchored_header.height()
635+
< naka_tip_tenure_start_header.anchored_header.height()
636636
{
637637
return Err(Error::InvalidStacksBlock(
638638
"Nakamoto tip is lower than its tenure-start block".into(),

stackslib/src/chainstate/stacks/index/trie.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,13 +372,8 @@ impl Trie {
372372
// append the new leaf and the end of the file.
373373
let new_leaf_disk_ptr = storage.last_ptr()?;
374374
let new_leaf_chr = cursor.path[cursor.tell()]; // NOTE: this is safe because !cursor.eop()
375-
let new_leaf_path = cursor.path[(if cursor.tell() + 1 <= cursor.path.len() {
376-
cursor.tell() + 1
377-
} else {
378-
cursor.path.len()
379-
})..]
380-
.to_vec();
381-
new_leaf_data.path = new_leaf_path;
375+
new_leaf_data.path =
376+
cursor.path[std::cmp::min(cursor.tell() + 1, cursor.path.len())..].to_vec();
382377
let new_leaf_hash = get_leaf_hash(new_leaf_data);
383378

384379
// put new leaf at the end of this Trie

stackslib/src/chainstate/stacks/tests/block_construction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2297,7 +2297,7 @@ fn test_build_anchored_blocks_invalid() {
22972297

22982298
eprintln!("\n\nat resume parent tenure:\nlast_parent: {:?}\nlast_parent_tip: {:?}\n\n", &last_parent, &last_parent_tip);
22992299
}
2300-
else if tenure_id >= bad_block_tenure + 1 {
2300+
else if tenure_id > bad_block_tenure {
23012301
last_parent = None;
23022302
last_parent_tip = None;
23032303
}

stackslib/src/net/relay.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl RelayerStats {
286286
let mut to_remove = vec![];
287287
for (ts, old_addr) in self.relay_updates.iter() {
288288
self.relay_stats.remove(old_addr);
289-
if self.relay_stats.len() <= MAX_RELAYER_STATS - 1 {
289+
if self.relay_stats.len() < MAX_RELAYER_STATS {
290290
break;
291291
}
292292
to_remove.push(*ts);
@@ -342,7 +342,7 @@ impl RelayerStats {
342342
let mut to_remove = vec![];
343343
for (ts, old_nk) in self.recent_updates.iter() {
344344
self.recent_messages.remove(old_nk);
345-
if self.recent_messages.len() <= MAX_RELAYER_STATS - 1 {
345+
if self.recent_messages.len() < MAX_RELAYER_STATS {
346346
break;
347347
}
348348
to_remove.push(*ts);

0 commit comments

Comments
 (0)