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 != 0 instead of > 0 for unsigned integer types #71

Closed
code423n4 opened this issue Dec 3, 2021 · 1 comment
Closed

Use != 0 instead of > 0 for unsigned integer types #71

code423n4 opened this issue Dec 3, 2021 · 1 comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Handle

pmerkleplant

Vulnerability details

When dealing with unsigned integer types, comparisons with != 0 are cheaper
then with >0.

Therefore, the following statements can be refactored to save gas:

./Locke.sol:226: if (acctTimeDelta > 0 && ts.tokens > 0)
./Locke.sol:236: if (tdelta > 0 && unstreamed > 0)
./Locke.sol:378: require(amount > 0, "amt");
./Locke.sol:418: require(amount > 0, "amt");
./Locke.sol:456: require(amount > 0, "amt");
./Locke.sol:522: require(amount > 0, "amt");
./Locke.sol:536: require(amount > 0, "amt");
./Locke.sol:572: require(rewardAmt > 0, "amt");
./Locke.sol:612: if (fees > 0)
./Locke.sol:679: if (incentives[token] > 0)
@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Dec 3, 2021
code423n4 added a commit that referenced this issue Dec 3, 2021
@brockelmore brockelmore added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Dec 3, 2021
@0xean
Copy link
Collaborator

0xean commented Jan 16, 2022

dupe of #143

@0xean 0xean closed this as completed Jan 16, 2022
@0xean 0xean added the duplicate This issue or pull request already exists label Jan 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

3 participants