chore: Fix clang-tidy issues

This commit is contained in:
Sergey Kuznetsov
2026-07-23 14:07:08 +01:00
parent d54ca4cd3b
commit cb6dad0bc4
4 changed files with 22 additions and 24 deletions

View File

@@ -45,11 +45,7 @@ WasmImpArgs(WasmImportFunc& e)
if constexpr (N < C)
{
using at = boost::mpl::at_c<Mpl, N>::type;
if constexpr (std::is_pointer_v<at>)
{
e.params.push_back(WasmTypes::WtI32);
}
else if constexpr (std::is_same_v<at, std::int32_t>)
if constexpr (std::is_pointer_v<at> || std::is_same_v<at, std::int32_t>)
{
e.params.push_back(WasmTypes::WtI32);
}
@@ -73,11 +69,7 @@ template <typename Rt>
void
WasmImpRet(WasmImportFunc& e)
{
if constexpr (std::is_pointer_v<Rt>)
{
e.result = WasmTypes::WtI32;
}
else if constexpr (std::is_same_v<Rt, std::int32_t>)
if constexpr (std::is_pointer_v<Rt> || std::is_same_v<Rt, std::int32_t>)
{
e.result = WasmTypes::WtI32;
}

View File

@@ -264,7 +264,7 @@ public:
return instanceWrap_.getFunc(funcName, exportTypes_);
}
wasm_functype_t*
wasm_functype_t const*
getFuncType(std::string_view funcName) const;
Wmem

View File

@@ -311,7 +311,10 @@ InstanceWrapper::setTransferLimit(std::int64_t x)
ModulePtr
ModuleWrapper::init(StorePtr& s, Bytes const& wasmBin, beast::Journal j)
{
wasm_byte_vec_t const code{.size = wasmBin.size(), .data = (char*)(wasmBin.data())};
wasm_byte_vec_t const code{
.size = wasmBin.size(),
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
.data = const_cast<char*>(reinterpret_cast<char const*>(wasmBin.data()))};
ModulePtr m = ModulePtr(wasm_module_new(s.get(), &code), &wasm_module_delete);
if (!m)
throw std::runtime_error("can't create module");
@@ -482,7 +485,7 @@ ModuleWrapper::buildImports(StorePtr& s, ImportVec const& imports) const
return wimports;
}
wasm_functype_t*
wasm_functype_t const*
ModuleWrapper::getFuncType(std::string_view funcName) const
{
for (size_t i = 0; i < exportTypes_.size(); i++)
@@ -493,7 +496,7 @@ ModuleWrapper::getFuncType(std::string_view funcName) const
if (wasm_externtype_kind(exnType) == WASM_EXTERN_FUNC &&
funcName == std::string_view(name->data, name->size))
{
return wasm_externtype_as_functype(const_cast<wasm_externtype_t*>(exnType));
return wasm_externtype_as_functype_const(exnType);
}
}

View File

@@ -3452,7 +3452,7 @@ struct HostFuncImpl_test : public beast::unit_test::Suite
BEAST_EXPECT(result[0].of.i32 == 0))
{
auto const messages = sink.messages().str();
BEAST_EXPECT(messages.find(msg) != std::string::npos);
BEAST_EXPECT(messages.contains(msg));
}
}
@@ -3471,8 +3471,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite
std::string hex;
hex.reserve(data.size() * 2);
boost::algorithm::hex(data.begin(), data.end(), std::back_inserter(hex));
BEAST_EXPECT(messages.find(msg) != std::string::npos);
BEAST_EXPECT(messages.find(hex) != std::string::npos);
BEAST_EXPECT(messages.contains(msg));
BEAST_EXPECT(messages.contains(hex));
}
}
}
@@ -3542,8 +3542,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite
BEAST_EXPECT(result[0].of.i32 == 0))
{
auto const messages = sink.messages().str();
BEAST_EXPECT(messages.find(msg) != std::string::npos);
BEAST_EXPECT(messages.find(std::to_string(num)) != std::string::npos);
BEAST_EXPECT(messages.contains(msg));
BEAST_EXPECT(messages.contains(std::to_string(num)));
}
}
@@ -3611,8 +3611,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite
BEAST_EXPECT(result[0].of.i32 == 0))
{
auto const messages = sink.messages().str();
BEAST_EXPECT(messages.find(msg) != std::string::npos);
BEAST_EXPECT(messages.find(env.master.human()) != std::string::npos);
BEAST_EXPECT(messages.contains(msg));
BEAST_EXPECT(messages.contains(env.master.human()));
}
}
@@ -3689,8 +3689,8 @@ struct HostFuncImpl_test : public beast::unit_test::Suite
BEAST_EXPECT(result[0].of.i32 == 0))
{
auto const messages = sink.messages().str();
BEAST_EXPECT(messages.find(msg) != std::string::npos);
BEAST_EXPECT(messages.find(amount.getFullText()) != std::string::npos);
BEAST_EXPECT(messages.contains(msg));
BEAST_EXPECT(messages.contains(amount.getFullText()));
}
}
@@ -6176,7 +6176,10 @@ struct HostFuncImpl_test : public beast::unit_test::Suite
// trace() uses getDataString() -> getDataSlice() which does NOT check transfer limit
std::string testMsg = "This message is longer than 10 bytes to prove slices don't count";
vrt.setBytes(0, testMsg.data(), testMsg.size());
vrt.setBytes(100, (uint8_t const*)"dummy", 5); // Empty data slice for trace
vrt.setBytes(
100,
reinterpret_cast<uint8_t const*>("dummy"),
5); // Empty data slice for trace
{
WasmValVec params(5), result(1);
// trace(msg_ptr, msg_len, data_ptr, data_len, asHex)