diff --git a/contracts/account/utils/draft-ERC7579Utils.sol b/contracts/account/utils/draft-ERC7579Utils.sol index 8be094e649d..3a9769dcb39 100644 --- a/contracts/account/utils/draft-ERC7579Utils.sol +++ b/contracts/account/utils/draft-ERC7579Utils.sol @@ -203,7 +203,7 @@ library ERC7579Utils { revert ERC7579DecodingError(); assembly ("memory-safe") { - executionBatch.offset := add(add(executionCalldata.offset, arrayLengthOffset), 32) + executionBatch.offset := add(add(executionCalldata.offset, arrayLengthOffset), 0x20) executionBatch.length := arrayLength } } diff --git a/contracts/governance/Governor.sol b/contracts/governance/Governor.sol index f45aba096eb..14a67013feb 100644 --- a/contracts/governance/Governor.sol +++ b/contracts/governance/Governor.sol @@ -840,7 +840,7 @@ abstract contract Governor is Context, ERC165, EIP712, Nonces, IGovernor, IERC72 function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) { // This is not memory safe in the general case, but all calls to this private function are within bounds. assembly ("memory-safe") { - value := mload(add(buffer, add(0x20, offset))) + value := mload(add(add(buffer, 0x20), offset)) } } } diff --git a/contracts/token/ERC1155/utils/ERC1155Utils.sol b/contracts/token/ERC1155/utils/ERC1155Utils.sol index 371cd86ba46..8796064fc61 100644 --- a/contracts/token/ERC1155/utils/ERC1155Utils.sol +++ b/contracts/token/ERC1155/utils/ERC1155Utils.sol @@ -42,7 +42,7 @@ library ERC1155Utils { revert IERC1155Errors.ERC1155InvalidReceiver(to); } else { assembly ("memory-safe") { - revert(add(32, reason), mload(reason)) + revert(add(reason, 0x20), mload(reason)) } } } @@ -79,7 +79,7 @@ library ERC1155Utils { revert IERC1155Errors.ERC1155InvalidReceiver(to); } else { assembly ("memory-safe") { - revert(add(32, reason), mload(reason)) + revert(add(reason, 0x20), mload(reason)) } } } diff --git a/contracts/token/ERC20/utils/ERC1363Utils.sol b/contracts/token/ERC20/utils/ERC1363Utils.sol index 6ba26901eb0..e2ce200809a 100644 --- a/contracts/token/ERC20/utils/ERC1363Utils.sol +++ b/contracts/token/ERC20/utils/ERC1363Utils.sol @@ -53,7 +53,7 @@ library ERC1363Utils { revert ERC1363InvalidReceiver(to); } else { assembly ("memory-safe") { - revert(add(32, reason), mload(reason)) + revert(add(reason, 0x20), mload(reason)) } } } @@ -87,7 +87,7 @@ library ERC1363Utils { revert ERC1363InvalidSpender(spender); } else { assembly ("memory-safe") { - revert(add(32, reason), mload(reason)) + revert(add(reason, 0x20), mload(reason)) } } } diff --git a/contracts/token/ERC721/utils/ERC721Utils.sol b/contracts/token/ERC721/utils/ERC721Utils.sol index 2fd091afd67..4ca31a2af7e 100644 --- a/contracts/token/ERC721/utils/ERC721Utils.sol +++ b/contracts/token/ERC721/utils/ERC721Utils.sol @@ -41,7 +41,7 @@ library ERC721Utils { revert IERC721Errors.ERC721InvalidReceiver(to); } else { assembly ("memory-safe") { - revert(add(32, reason), mload(reason)) + revert(add(reason, 0x20), mload(reason)) } } } diff --git a/contracts/utils/Address.sol b/contracts/utils/Address.sol index d8e88749148..c255035a01b 100644 --- a/contracts/utils/Address.sol +++ b/contracts/utils/Address.sol @@ -140,8 +140,7 @@ library Address { if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly ("memory-safe") { - let returndata_size := mload(returndata) - revert(add(32, returndata), returndata_size) + revert(add(returndata, 0x20), mload(returndata)) } } else { revert Errors.FailedCall(); diff --git a/contracts/utils/Bytes.sol b/contracts/utils/Bytes.sol index cf0cb8fcd7f..56ac20b90e1 100644 --- a/contracts/utils/Bytes.sol +++ b/contracts/utils/Bytes.sol @@ -92,7 +92,7 @@ library Bytes { // allocate and copy bytes memory result = new bytes(end - start); assembly ("memory-safe") { - mcopy(add(result, 0x20), add(buffer, add(start, 0x20)), sub(end, start)) + mcopy(add(result, 0x20), add(add(buffer, 0x20), start), sub(end, start)) } return result; @@ -107,7 +107,7 @@ library Bytes { function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) { // This is not memory safe in the general case, but all calls to this private function are within bounds. assembly ("memory-safe") { - value := mload(add(buffer, add(0x20, offset))) + value := mload(add(add(buffer, 0x20), offset)) } } } diff --git a/contracts/utils/Strings.sol b/contracts/utils/Strings.sol index f9465eaf04d..9611115ace1 100644 --- a/contracts/utils/Strings.sol +++ b/contracts/utils/Strings.sol @@ -40,7 +40,7 @@ library Strings { string memory buffer = new string(length); uint256 ptr; assembly ("memory-safe") { - ptr := add(buffer, add(32, length)) + ptr := add(add(buffer, 0x20), length) } while (true) { ptr--; @@ -435,7 +435,7 @@ library Strings { function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) { // This is not memory safe in the general case, but all calls to this private function are within bounds. assembly ("memory-safe") { - value := mload(add(buffer, add(0x20, offset))) + value := mload(add(add(buffer, 0x20), offset)) } } }