Fix relevant warnings (#3685)

This commit is contained in:
Francisco
2022-09-07 15:56:18 -03:00
committed by GitHub
parent 5d31ad0eb9
commit 3c552e6e03
4 changed files with 33 additions and 33 deletions

View File

@ -34,8 +34,8 @@ library Checkpoints {
require(blockNumber < block.number, "Checkpoints: block not yet mined");
uint32 key = SafeCast.toUint32(blockNumber);
uint256 length = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, length);
uint256 len = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
@ -49,13 +49,13 @@ library Checkpoints {
require(blockNumber < block.number, "Checkpoints: block not yet mined");
uint32 key = SafeCast.toUint32(blockNumber);
uint256 length = self._checkpoints.length;
uint256 len = self._checkpoints.length;
uint256 low = 0;
uint256 high = length;
uint256 high = len;
if (length > 5) {
uint256 mid = length - Math.sqrt(length);
if (len > 5) {
uint256 mid = len - Math.sqrt(len);
if (key < _unsafeAccess(self._checkpoints, mid)._blockNumber) {
high = mid;
} else {
@ -205,7 +205,7 @@ library Checkpoints {
return high;
}
function _unsafeAccess(Checkpoint[] storage self, uint256 pos) private view returns (Checkpoint storage result) {
function _unsafeAccess(Checkpoint[] storage self, uint256 pos) private pure returns (Checkpoint storage result) {
assembly {
mstore(0, self.slot)
result.slot := add(keccak256(0, 0x20), pos)
@ -238,17 +238,17 @@ library Checkpoints {
* @dev Returns the value in the oldest checkpoint with key greater or equal than the search key, or zero if there is none.
*/
function lowerLookup(Trace224 storage self, uint32 key) internal view returns (uint224) {
uint256 length = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, length);
return pos == length ? 0 : _unsafeAccess(self._checkpoints, pos)._value;
uint256 len = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value;
}
/**
* @dev Returns the value in the most recent checkpoint with key lower or equal than the search key.
*/
function upperLookup(Trace224 storage self, uint32 key) internal view returns (uint224) {
uint256 length = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, length);
uint256 len = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
@ -368,7 +368,7 @@ library Checkpoints {
function _unsafeAccess(Checkpoint224[] storage self, uint256 pos)
private
view
pure
returns (Checkpoint224 storage result)
{
assembly {
@ -403,17 +403,17 @@ library Checkpoints {
* @dev Returns the value in the oldest checkpoint with key greater or equal than the search key, or zero if there is none.
*/
function lowerLookup(Trace160 storage self, uint96 key) internal view returns (uint160) {
uint256 length = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, length);
return pos == length ? 0 : _unsafeAccess(self._checkpoints, pos)._value;
uint256 len = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value;
}
/**
* @dev Returns the value in the most recent checkpoint with key lower or equal than the search key.
*/
function upperLookup(Trace160 storage self, uint96 key) internal view returns (uint160) {
uint256 length = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, length);
uint256 len = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
@ -533,7 +533,7 @@ library Checkpoints {
function _unsafeAccess(Checkpoint160[] storage self, uint256 pos)
private
view
pure
returns (Checkpoint160 storage result)
{
assembly {