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

Use saturating_sub instead of - for unsigned ints #1530

Merged
merged 2 commits into from
Feb 20, 2023

Conversation

rumpl
Copy link
Contributor

@rumpl rumpl commented Jan 31, 2023

This fixes a panic if the operation with the unsigned ints would result in a negative number

@codecov-commenter
Copy link

codecov-commenter commented Jan 31, 2023

Codecov Report

Merging #1530 (9af9b16) into main (3675a51) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1530   +/-   ##
=======================================
  Coverage   68.74%   68.75%           
=======================================
  Files         120      120           
  Lines       13094    13094           
=======================================
+ Hits         9002     9003    +1     
+ Misses       4092     4091    -1     

@YJDoc2
Copy link
Collaborator

YJDoc2 commented Feb 1, 2023

Hey @rumpl , the formatting check is failing in the CI. Can you run cargo fmt, and push again. Also if possible, can you amend the current commit instead of adding a new one for formatting.

I am also curious if we should do a similar saturating operation for other additions or subtractions related to such cgroups values. What do you think?

@rumpl
Copy link
Contributor Author

rumpl commented Feb 1, 2023

Hey, I created a new PR that only fixes formatting, the failures are unrelated to the changes I made here, the PR: #1532

@rumpl
Copy link
Contributor Author

rumpl commented Feb 1, 2023

I am also curious if we should do a similar saturating operation for other additions or subtractions related to such cgroups values. What do you think?

I looked briefly but didn't see any other code where there are subtractions with unsigned ints

Ok nevermind, I found other places where there was unsigned subtrations, fixed them

@rumpl rumpl force-pushed the unsigned_saturating_sub branch 2 times, most recently from 9af9b16 to e92e7e3 Compare February 1, 2023 09:05
@utam0k
Copy link
Member

utam0k commented Feb 2, 2023

@rumpl May I ask you to rebase from the latest main branch?

This fixes a panic if the operation with the unsigned ints would result
in a negative number

Signed-off-by: Djordje Lukic <[email protected]>
@rumpl rumpl force-pushed the unsigned_saturating_sub branch from e92e7e3 to e01e604 Compare February 3, 2023 09:31
@rumpl
Copy link
Contributor Author

rumpl commented Feb 3, 2023

@utam0k done 👍

Copy link
Collaborator

@YJDoc2 YJDoc2 left a comment

Choose a reason for hiding this comment

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

lgtm 👍

@YJDoc2
Copy link
Collaborator

YJDoc2 commented Feb 20, 2023

Thanks a lot!

@YJDoc2 YJDoc2 merged commit 6c7f332 into youki-dev:main Feb 20, 2023
@rumpl rumpl deleted the unsigned_saturating_sub branch February 20, 2023 13:31
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.

4 participants