Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Wang committed Nov 28, 2023
1 parent d688672 commit 99da5c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions contracts/Comet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -208,23 +208,23 @@ contract Comet is CometMainInterface {
}

function nonReentrantBefore() internal {
bytes32 slot = COMET_REENTRANCY_GUARD_FLAG_SLOT;
bytes32 slot = REENTRANCY_GUARD_FLAG_SLOT;
uint256 status;
assembly {

Check warning on line 213 in contracts/Comet.sol

View workflow job for this annotation

GitHub Actions / Contract linter

Avoid to use inline assembly. It is acceptable only in rare cases
status := sload(slot)
}

if (status == COMET_REENTRANCY_GUARD_ENTERED) revert ReentrantCallBlocked();
if (status == REENTRANCY_GUARD_ENTERED) revert ReentrantCallBlocked();
assembly {

Check warning on line 218 in contracts/Comet.sol

View workflow job for this annotation

GitHub Actions / Contract linter

Avoid to use inline assembly. It is acceptable only in rare cases
sstore(slot, COMET_REENTRANCY_GUARD_ENTERED)
sstore(slot, REENTRANCY_GUARD_ENTERED)
}
}

function nonReentrantAfter() internal {
bytes32 slot = COMET_REENTRANCY_GUARD_FLAG_SLOT;
bytes32 slot = REENTRANCY_GUARD_FLAG_SLOT;
uint256 status;

Check warning on line 225 in contracts/Comet.sol

View workflow job for this annotation

GitHub Actions / Contract linter

Variable "status" is unused
assembly {

Check warning on line 226 in contracts/Comet.sol

View workflow job for this annotation

GitHub Actions / Contract linter

Avoid to use inline assembly. It is acceptable only in rare cases
sstore(slot, COMET_REENTRANCY_GUARD_NOT_ENTERED)
sstore(slot, REENTRANCY_GUARD_NOT_ENTERED)
}
}

Expand Down Expand Up @@ -1320,6 +1320,7 @@ contract Comet is CometMainInterface {
*/
function approveThis(address manager, address asset, uint amount) override external {
if (msg.sender != governor) revert Unauthorized();

IERC20NonStandard(asset).approve(manager, amount);
}

Expand Down
8 changes: 4 additions & 4 deletions contracts/CometCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ abstract contract CometCore is CometConfiguration, CometStorage, CometMath {
uint64 internal constant FACTOR_SCALE = 1e18;

/// @dev The storage slot for reentrancy guard flags
bytes32 internal constant COMET_REENTRANCY_GUARD_FLAG_SLOT = bytes32(keccak256("comet.reentrancy.guard"));
bytes32 internal constant REENTRANCY_GUARD_FLAG_SLOT = bytes32(keccak256("comet.reentrancy.guard"));

/// @dev The reentrancy guard status
uint256 internal constant COMET_REENTRANCY_GUARD_NOT_ENTERED = 0;
uint256 internal constant COMET_REENTRANCY_GUARD_ENTERED = 1;
/// @dev The reentrancy guard statuses
uint256 internal constant REENTRANCY_GUARD_NOT_ENTERED = 0;
uint256 internal constant REENTRANCY_GUARD_ENTERED = 1;

/**
* @notice Determine if the manager has permission to act on behalf of the owner
Expand Down

0 comments on commit 99da5c4

Please sign in to comment.