Skip to content

Commit 23f9dad

Browse files
committed
fix: avoid variable shadowing (C4 QA)
1 parent e3a668e commit 23f9dad

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

contracts/governance/Controller.sol

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,19 @@ contract Controller is Governed, Pausable, IController {
9494
/**
9595
* @notice Change the partial paused state of the contract
9696
* Partial pause is intended as a partial pause of the protocol
97+
* @param _toPause True if the contracts should be (partially) paused, false otherwise
9798
*/
98-
function setPartialPaused(bool _partialPaused) external override onlyGovernorOrGuardian {
99-
_setPartialPaused(_partialPaused);
99+
function setPartialPaused(bool _toPause) external override onlyGovernorOrGuardian {
100+
_setPartialPaused(_toPause);
100101
}
101102

102103
/**
103104
* @notice Change the paused state of the contract
104105
* Full pause most of protocol functions
106+
* @param _toPause True if the contracts should be paused, false otherwise
105107
*/
106-
function setPaused(bool _paused) external override onlyGovernorOrGuardian {
107-
_setPaused(_paused);
108+
function setPaused(bool _toPause) external override onlyGovernorOrGuardian {
109+
_setPaused(_toPause);
108110
}
109111

110112
/**

contracts/upgrades/GraphProxy.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ contract GraphProxy is GraphProxyStorage {
1919
* the sender is the admin.
2020
*/
2121
modifier ifAdmin() {
22-
if (msg.sender == _admin()) {
22+
if (msg.sender == _getAdmin()) {
2323
_;
2424
} else {
2525
_fallback();
@@ -31,7 +31,7 @@ contract GraphProxy is GraphProxyStorage {
3131
* the sender is the admin or pending implementation.
3232
*/
3333
modifier ifAdminOrPendingImpl() {
34-
if (msg.sender == _admin() || msg.sender == _pendingImplementation()) {
34+
if (msg.sender == _getAdmin() || msg.sender == _getPendingImplementation()) {
3535
_;
3636
} else {
3737
_fallback();
@@ -67,7 +67,7 @@ contract GraphProxy is GraphProxyStorage {
6767
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
6868
*/
6969
function admin() external ifAdminOrPendingImpl returns (address) {
70-
return _admin();
70+
return _getAdmin();
7171
}
7272

7373
/**
@@ -80,7 +80,7 @@ contract GraphProxy is GraphProxyStorage {
8080
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
8181
*/
8282
function implementation() external ifAdminOrPendingImpl returns (address) {
83-
return _implementation();
83+
return _getImplementation();
8484
}
8585

8686
/**
@@ -93,7 +93,7 @@ contract GraphProxy is GraphProxyStorage {
9393
* `0x9e5eddc59e0b171f57125ab86bee043d9128098c3a6b9adb4f2e86333c2f6f8c`
9494
*/
9595
function pendingImplementation() external ifAdminOrPendingImpl returns (address) {
96-
return _pendingImplementation();
96+
return _getPendingImplementation();
9797
}
9898

9999
/**
@@ -129,15 +129,15 @@ contract GraphProxy is GraphProxyStorage {
129129
function acceptUpgradeAndCall(bytes calldata data) external ifAdminOrPendingImpl {
130130
_acceptUpgrade();
131131
// solhint-disable-next-line avoid-low-level-calls
132-
(bool success, ) = _implementation().delegatecall(data);
132+
(bool success, ) = _getImplementation().delegatecall(data);
133133
require(success);
134134
}
135135

136136
/**
137137
* @dev Admin function for new implementation to accept its role as implementation.
138138
*/
139139
function _acceptUpgrade() internal {
140-
address _pendingImplementation = _pendingImplementation();
140+
address _pendingImplementation = _getPendingImplementation();
141141
require(Address.isContract(_pendingImplementation), "Impl must be a contract");
142142
require(_pendingImplementation != address(0), "Impl cannot be zero address");
143143
require(msg.sender == _pendingImplementation, "Only pending implementation");
@@ -152,7 +152,7 @@ contract GraphProxy is GraphProxyStorage {
152152
* external caller.
153153
*/
154154
function _fallback() internal {
155-
require(msg.sender != _admin(), "Cannot fallback to proxy target");
155+
require(msg.sender != _getAdmin(), "Cannot fallback to proxy target");
156156

157157
assembly {
158158
// (a) get free memory pointer

contracts/upgrades/GraphProxyStorage.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ contract GraphProxyStorage {
5959
* @dev Modifier to check whether the `msg.sender` is the admin.
6060
*/
6161
modifier onlyAdmin() {
62-
require(msg.sender == _admin(), "Caller must be admin");
62+
require(msg.sender == _getAdmin(), "Caller must be admin");
6363
_;
6464
}
6565

6666
/**
6767
* @return adm The admin slot.
6868
*/
69-
function _admin() internal view returns (address adm) {
69+
function _getAdmin() internal view returns (address adm) {
7070
bytes32 slot = ADMIN_SLOT;
7171
assembly {
7272
adm := sload(slot)
@@ -83,14 +83,14 @@ contract GraphProxyStorage {
8383
sstore(slot, _newAdmin)
8484
}
8585

86-
emit AdminUpdated(_admin(), _newAdmin);
86+
emit AdminUpdated(_getAdmin(), _newAdmin);
8787
}
8888

8989
/**
9090
* @dev Returns the current implementation.
9191
* @return impl Address of the current implementation
9292
*/
93-
function _implementation() internal view returns (address impl) {
93+
function _getImplementation() internal view returns (address impl) {
9494
bytes32 slot = IMPLEMENTATION_SLOT;
9595
assembly {
9696
impl := sload(slot)
@@ -101,7 +101,7 @@ contract GraphProxyStorage {
101101
* @dev Returns the current pending implementation.
102102
* @return impl Address of the current pending implementation
103103
*/
104-
function _pendingImplementation() internal view returns (address impl) {
104+
function _getPendingImplementation() internal view returns (address impl) {
105105
bytes32 slot = PENDING_IMPLEMENTATION_SLOT;
106106
assembly {
107107
impl := sload(slot)
@@ -113,7 +113,7 @@ contract GraphProxyStorage {
113113
* @param _newImplementation Address of the new implementation
114114
*/
115115
function _setImplementation(address _newImplementation) internal {
116-
address oldImplementation = _implementation();
116+
address oldImplementation = _getImplementation();
117117

118118
bytes32 slot = IMPLEMENTATION_SLOT;
119119
assembly {
@@ -128,7 +128,7 @@ contract GraphProxyStorage {
128128
* @param _newImplementation Address of the new pending implementation
129129
*/
130130
function _setPendingImplementation(address _newImplementation) internal {
131-
address oldPendingImplementation = _pendingImplementation();
131+
address oldPendingImplementation = _getPendingImplementation();
132132

133133
bytes32 slot = PENDING_IMPLEMENTATION_SLOT;
134134
assembly {

0 commit comments

Comments
 (0)