Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix int_plus_one warnings #5626

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stackslib/src/chainstate/nakamoto/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,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 @@ -375,13 +375,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();
jcnelson marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -2327,7 +2327,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
Loading