@@ -65,22 +65,16 @@ Pairs toPairs(std::string_view buffer) {
65
65
if (buffer.size () < sizeof (uint32_t )) {
66
66
return {};
67
67
}
68
- bool reverse = " null" != contextOrEffectiveContext ()->wasmVm ()->getEngineName ();
69
- auto size = reverse ? wasmtoh (*reinterpret_cast <const uint32_t *>(b))
70
- : *reinterpret_cast <const uint32_t *>(b);
68
+ auto size = wasmtoh (*reinterpret_cast <const uint32_t *>(b));
71
69
b += sizeof (uint32_t );
72
70
if (sizeof (uint32_t ) + size * 2 * sizeof (uint32_t ) > buffer.size ()) {
73
71
return {};
74
72
}
75
73
result.resize (size);
76
74
for (uint32_t i = 0 ; i < size; i++) {
77
- result[i].first =
78
- std::string_view (nullptr , reverse ? wasmtoh (*reinterpret_cast <const uint32_t *>(b))
79
- : *reinterpret_cast <const uint32_t *>(b));
75
+ result[i].first = std::string_view (nullptr , wasmtoh (*reinterpret_cast <const uint32_t *>(b)));
80
76
b += sizeof (uint32_t );
81
- result[i].second =
82
- std::string_view (nullptr , reverse ? wasmtoh (*reinterpret_cast <const uint32_t *>(b))
83
- : *reinterpret_cast <const uint32_t *>(b));
77
+ result[i].second = std::string_view (nullptr , wasmtoh (*reinterpret_cast <const uint32_t *>(b)));
84
78
b += sizeof (uint32_t );
85
79
}
86
80
for (auto &p : result) {
@@ -697,7 +691,6 @@ Word wasi_unstable_fd_prestat_dir_name(Word /*fd*/, Word /*path_ptr*/, Word /*pa
697
691
// logs.
698
692
Word writevImpl (Word fd, Word iovs, Word iovs_len, Word *nwritten_ptr) {
699
693
auto *context = contextOrEffectiveContext ();
700
- bool reverse = " null" != context->wasmVm ()->getEngineName ();
701
694
702
695
// Read syscall args.
703
696
uint64_t log_level;
@@ -721,9 +714,8 @@ Word writevImpl(Word fd, Word iovs, Word iovs_len, Word *nwritten_ptr) {
721
714
}
722
715
const auto *iovec = reinterpret_cast <const uint32_t *>(memslice.value ().data ());
723
716
if (iovec[1 ] != 0U /* buf_len */ ) {
724
- auto iovec0 = reverse ? wasmtoh (iovec[0 ]) : iovec[0 ];
725
- auto iovec1 = reverse ? wasmtoh (iovec[1 ]) : iovec[1 ];
726
- memslice = context->wasmVm ()->getMemory (iovec0 /* buf */ , iovec1 /* buf_len */ );
717
+ memslice = context->wasmVm ()->getMemory (wasmtoh (iovec[0 ]) /* buf */ ,
718
+ wasmtoh (iovec[1 ]) /* buf_len */ );
727
719
if (!memslice) {
728
720
return 21 ; // __WASI_EFAULT
729
721
}
0 commit comments