From c77e4369bccd4f98b1c5697520a79dc1815dec73 Mon Sep 17 00:00:00 2001 From: liu-zelin Date: Sat, 10 Aug 2024 10:32:53 +0800 Subject: [PATCH] Fix type mismatch Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAJ43L?from=project-issue Signed-off-by: liu-zelin Change-Id: Ifc72780a31c5a48a461596e83b1b6151e3456260 --- ecmascript/serializer/serialize_data.h | 12 ++++++------ ecmascript/serializer/value_serializer.cpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ecmascript/serializer/serialize_data.h b/ecmascript/serializer/serialize_data.h index 0be4d2e555..0788e15f22 100644 --- a/ecmascript/serializer/serialize_data.h +++ b/ecmascript/serializer/serialize_data.h @@ -176,22 +176,22 @@ public: return RawDataEmit(data, length, bufferSize_); } - ssize_t RawDataEmit(const void *data, size_t length, ssize_t offset) + ssize_t RawDataEmit(const void *data, size_t length, size_t offset) { - if (length <= 0 || offset < 0) { + if (length <= 0) { return -1; } - if ((static_cast(offset) + length) > bufferCapacity_) { + if ((offset + length) > bufferCapacity_) { if (!AllocateBuffer(length)) { return -1; } } - if (memcpy_s(buffer_ + offset, bufferCapacity_ - static_cast(offset), data, length) != EOK) { + if (memcpy_s(buffer_ + offset, bufferCapacity_ - offset, data, length) != EOK) { LOG_FULL(ERROR) << "Failed to memcpy_s Data"; return -1; } ssize_t res = offset; - if (bufferSize_ == static_cast(offset)) { + if (bufferSize_ == offset) { bufferSize_ += length; } return res; @@ -207,7 +207,7 @@ public: return RawDataEmit(reinterpret_cast(&c), U64_SIZE); } - ssize_t EmitU64(uint64_t c, ssize_t offset) + ssize_t EmitU64(uint64_t c, size_t offset) { return RawDataEmit(reinterpret_cast(&c), U64_SIZE, offset); } diff --git a/ecmascript/serializer/value_serializer.cpp b/ecmascript/serializer/value_serializer.cpp index 80aa830ec1..1cc827d658 100644 --- a/ecmascript/serializer/value_serializer.cpp +++ b/ecmascript/serializer/value_serializer.cpp @@ -125,13 +125,13 @@ bool ValueSerializer::WriteValue(JSThread *thread, for (auto &entry : detachCallbackInfo_) { auto info = entry.second; DetachFunc detachNative = reinterpret_cast(info->detachFunc); - if (detachNative == nullptr || !(entry.first >= 0)) { + if (detachNative == nullptr || entry.first < 0) { LOG_ECMA(ERROR) << "ValueSerialize: SerializeNativeBindingObject detachNative == nullptr"; notSupport_ = true; return false; } void *buffer = detachNative(info->env, info->nativeValue, info->hint, info->detachData); - data_->EmitU64(reinterpret_cast(buffer), entry.first); + data_->EmitU64(reinterpret_cast(buffer), static_cast(entry.first)); } } if (notSupport_) {