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

Calculate distance between u64 without overflow #9592

Merged
merged 2 commits into from
Apr 20, 2020

Conversation

aeyakovenko
Copy link
Member

Problem

u64 unchecked subtract

Summary of Changes

calculate a numerical distance instead

Fixes #9590

@codecov
Copy link

codecov bot commented Apr 20, 2020

Codecov Report

Merging #9592 into master will decrease coverage by 0.0%.
The diff coverage is 100.0%.

@@           Coverage Diff            @@
##           master   #9592     +/-   ##
========================================
- Coverage    80.6%   80.6%   -0.1%     
========================================
  Files         279     279             
  Lines       63564   63578     +14     
========================================
+ Hits        51245   51253      +8     
- Misses      12319   12325      +6     

Copy link
Member

@sakridge sakridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@@ -412,11 +412,19 @@ pub fn broadcast_shreds(
Ok(())
}

fn distance(a: u64, b: u64) -> u64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call this abs for absolute value? (same name as std::num crate)

@aeyakovenko aeyakovenko merged commit 77fb423 into solana-labs:master Apr 20, 2020
mergify bot pushed a commit that referenced this pull request Apr 20, 2020
* fix overflow

* fixed num_live_peers overflow

(cherry picked from commit 77fb423)

# Conflicts:
#	core/src/broadcast_stage.rs
mergify bot pushed a commit that referenced this pull request Apr 20, 2020
* fix overflow

* fixed num_live_peers overflow

(cherry picked from commit 77fb423)
solana-grimes pushed a commit that referenced this pull request Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ContactInfo wallclock integer overflow
3 participants