Skip to content

Commit ec68d96

Browse files
committed
wasmtime: fix clang-tidy errors
Signed-off-by: Matt Leon <mattleon@google.com>
1 parent af0bb60 commit ec68d96

2 files changed

Lines changed: 16 additions & 18 deletions

File tree

BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ cc_library(
189189
cc_library(
190190
name = "wasmtime_lib",
191191
srcs = [
192-
"src/common/types.h",
193192
"src/wasmtime/wasmtime.cc",
194193
],
195194
hdrs = ["include/proxy-wasm/wasmtime.h"],

src/wasmtime/wasmtime.cc

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ using ::wasmtime::Store;
5858
using ::wasmtime::Table;
5959
using ::wasmtime::TrapResult;
6060

61-
} // namespace
62-
63-
static Engine *engine() {
61+
Engine *engine() {
6462
static auto *const engine = []() {
6563
Config config;
6664
config.epoch_interruption(true);
@@ -69,9 +67,21 @@ static Engine *engine() {
6967
return engine;
7068
}
7169

70+
template <typename T> std::string printValue(const T &value) { return std::to_string(value); }
71+
template <> std::string printValue(const proxy_wasm::Word &value) {
72+
return std::to_string(value.u64_);
73+
}
74+
75+
std::string printValues() { return ""; }
76+
template <typename Arg, typename... Args> std::string printValues(Arg arg, Args... args) {
77+
return printValue(arg) + ((", " + printValue(args)) + ... + "");
78+
}
79+
80+
} // namespace
81+
7282
class Wasmtime : public WasmVm {
7383
public:
74-
Wasmtime() : linker_(*engine()){};
84+
Wasmtime() = default;
7585

7686
std::string_view getEngineName() override { return "wasmtime"; }
7787
Cloneable cloneable() override { return Cloneable::CompiledBytecode; }
@@ -134,7 +144,7 @@ class Wasmtime : public WasmVm {
134144
std::optional<Instance> instance_;
135145
std::optional<Memory> memory_;
136146
std::optional<Table> table_;
137-
Linker linker_;
147+
Linker linker_ = Linker(*engine());
138148

139149
std::unordered_map<std::string, ::wasmtime::Func> module_functions_;
140150
};
@@ -193,17 +203,6 @@ std::unique_ptr<WasmVm> Wasmtime::clone() {
193203

194204
return clone;
195205
}
196-
template <typename T> static std::string printValue(const T &value) {
197-
return std::to_string(value);
198-
}
199-
template <> std::string printValue(const proxy_wasm::Word &value) {
200-
return std::to_string(value.u64_);
201-
}
202-
203-
static std::string printValues() { return ""; }
204-
template <typename Arg, typename... Args> static std::string printValues(Arg arg, Args... args) {
205-
return printValue(arg) + ((", " + printValue(args)) + ... + "");
206-
}
207206

208207
bool Wasmtime::link(std::string_view /*debug_name*/) {
209208
assert(module_.has_value());
@@ -245,7 +244,7 @@ std::optional<std::string_view> Wasmtime::getMemory(uint64_t pointer, uint64_t s
245244
if (pointer + size > data.size()) {
246245
return std::nullopt;
247246
}
248-
return std::string_view((char *)(data.data() + pointer), size);
247+
return std::string_view(reinterpret_cast<char *>(data.data() + pointer), size);
249248
}
250249

251250
bool Wasmtime::setMemory(uint64_t pointer, uint64_t size, const void *data) {

0 commit comments

Comments
 (0)