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 f2a559f8a5..09ebeb0059 100644 --- a/ecmascript/serializer/value_serializer.cpp +++ b/ecmascript/serializer/value_serializer.cpp @@ -126,13 +126,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; break; } 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_) {