Skip to content

Commit 411c75a

Browse files
authored
tidy: Properly set internal linkage to internal functions (#1104)
This sets the internal linkage of functions which should have it. `inline` nor `constexpr` functions don't have internal linkage so use `static` or put them in the anonymous namespace. These issues are found with clang-tidy's misc-use-internal-linkage.
1 parent 95b14d5 commit 411c75a

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

lib/evmone/advanced_analysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace evmone::advanced
99
{
1010
/// Clamps x to the max value of To type.
1111
template <typename To, typename T>
12-
inline constexpr To clamp(T x) noexcept
12+
static constexpr To clamp(T x) noexcept
1313
{
1414
constexpr auto max = std::numeric_limits<To>::max();
1515
return x <= max ? static_cast<To>(x) : max;
@@ -219,7 +219,7 @@ AdvancedCodeAnalysis analyze(evmc_revision rev, bytes_view code) noexcept
219219

220220
assert(analysis.instrs.size() <= max_instrs_size);
221221

222-
// Make sure the push_values has not been reallocated. Otherwise iterators are invalid.
222+
// Make sure the push_values has not been reallocated. Otherwise, iterators are invalid.
223223
assert(analysis.push_values.size() <= max_args_storage_size);
224224

225225
return analysis;

lib/evmone_precompiles/sha256.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static bool calc_chunk(uint8_t chunk[CHUNK_SIZE], struct BufferState* state)
135135
return true;
136136
}
137137

138-
[[gnu::always_inline, msvc::forceinline]] inline void sha_256_implementation(
138+
[[gnu::always_inline, msvc::forceinline]] static void sha_256_implementation(
139139
uint32_t h[8], const std::byte* input, size_t len)
140140
{
141141
/*

test/statetest/statetest_loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ state::AccessList from_json<state::AccessList>(const json::json& j)
122122
}
123123

124124
// Based on calculateEIP1559BaseFee from ethereum/retesteth
125-
inline uint64_t calculate_current_base_fee_eip1559(
125+
static uint64_t calculate_current_base_fee_eip1559(
126126
uint64_t parent_gas_used, uint64_t parent_gas_limit, uint64_t parent_base_fee)
127127
{
128128
// TODO: Make sure that 64-bit precision is good enough.

test/unittests/precompiles_ripemd160_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
using evmone::crypto::ripemd160;
1111

12-
inline std::string hex(std::span<const std::byte> x)
12+
static std::string hex(std::span<const std::byte> x)
1313
{
1414
return evmc::hex({reinterpret_cast<const unsigned char*>(x.data()), x.size()});
1515
}

test/unittests/state_rlp_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ struct CustomStruct
115115
bytes b;
116116
};
117117

118-
inline bytes rlp_encode(const CustomStruct& t)
118+
static bytes rlp_encode(const CustomStruct& t)
119119
{
120120
return rlp::encode_tuple(t.a, t.b);
121121
}
@@ -156,7 +156,7 @@ TEST(state_rlp, encode_uint64)
156156
EXPECT_EQ(rlp::encode(uint64_t{0xffffffffffffffff}), "88ffffffffffffffff"_hex);
157157
}
158158

159-
inline bytes to_significant_be_bytes(uint64_t x)
159+
static bytes to_significant_be_bytes(uint64_t x)
160160
{
161161
const auto byte_width = (std::bit_width(x) + 7) / 8;
162162
const auto leading_zero_bits = std::countl_zero(x) & ~7; // Leading bits rounded down to 8x.
@@ -169,7 +169,7 @@ inline bytes to_significant_be_bytes(uint64_t x)
169169

170170
/// The "custom" implementation of RLP encoding of uint64. It trims leading zero bytes and
171171
/// manually constructs bytes with variadic-length encoding.
172-
inline bytes rlp_encode_uint64(uint64_t x)
172+
static bytes rlp_encode_uint64(uint64_t x)
173173
{
174174
static constexpr uint8_t ShortBase = 0x80;
175175
if (x < ShortBase) // Single-byte encoding.

0 commit comments

Comments
 (0)