Skip to content

Commit

Permalink
Fix compiler warnings
Browse files Browse the repository at this point in the history
* Avoid reinterpret_cast
* Remove pointless #define _GNU_SOURCE. It is already defined by gyp,
  and defining it after all the includes does nothing anyway.
* Avoid using Nothing for primitives, they are not initialized.
* unary minus operator applied to unsigned type, result still unsigned
  • Loading branch information
orgads committed Jan 20, 2024
1 parent fc9d899 commit 4e5a0e5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/external_copy/serializer_nortti.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void SerializerDelegate::ThrowDataCloneError(Local<String> message) {

auto SerializerDelegate::GetSharedArrayBufferId(
Isolate* /*isolate*/, Local<SharedArrayBuffer> shared_array_buffer) -> Maybe<uint32_t> {
auto result = Nothing<uint32_t>();
auto result = Just<uint32_t>(0);
detail::RunBarrier([&]() {
transferables.emplace_back(std::make_unique<ExternalCopySharedArrayBuffer>(shared_array_buffer));
result = Just<uint32_t>(transferables.size() - 1);
Expand All @@ -34,7 +34,7 @@ auto SerializerDelegate::GetWasmModuleTransferId(
}

auto SerializerDelegate::WriteHostObject(Isolate* /*isolate*/, Local<Object> object) -> Maybe<bool> {
auto result = Nothing<bool>();
auto result = Just<bool>(false);
detail::RunBarrier([&]() {
serializer->WriteUint32(transferables.size());
transferables.emplace_back(TransferOut(object));
Expand Down
2 changes: 1 addition & 1 deletion src/isolate/allocator_nortti.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ExternalMemoryHandle {
~ExternalMemoryHandle() {
auto* allocator = IsolateEnvironment::GetCurrent().GetLimitedAllocator();
if (allocator != nullptr) {
allocator->AdjustAllocatedSize(-size);
allocator->AdjustAllocatedSize(-static_cast<ptrdiff_t>(size));
}
};

Expand Down
1 change: 0 additions & 1 deletion src/isolate/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ static auto GetStackBase() -> void* {
return base;
}
#elif defined __unix__
#define _GNU_SOURCE
static auto GetStackBase() -> void* {
pthread_t self = pthread_self();
pthread_attr_t attrs;
Expand Down
7 changes: 6 additions & 1 deletion src/module/lib_handle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ auto LibHandle::Hrtime(MaybeLocal<Array> maybe_diff) -> Local<Value> {
auto LibHandle::PrivateSymbol(MaybeLocal<String> maybe_name) -> Local<Value> {
Local<String> name{};
if (maybe_name.ToLocal(&name)) { /* nothing */ }
union {
Local<Private> *symbol;
Local<Value> *value;
} cast;
auto symbol = Private::New(Isolate::GetCurrent(), name);
return *reinterpret_cast<Local<Value>*>(&symbol);
cast.symbol = &symbol;
return *cast.value;
}

// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
Expand Down

0 comments on commit 4e5a0e5

Please sign in to comment.