!8621 Fix type mismatch

Merge pull request !8621 from diartyz/type_mismatch
This commit is contained in:
openharmony_ci 2024-08-12 22:55:05 +00:00 committed by Gitee
commit 188a6fec98
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 8 additions and 8 deletions

View File

@ -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<size_t>(offset) + length) > bufferCapacity_) {
if ((offset + length) > bufferCapacity_) {
if (!AllocateBuffer(length)) {
return -1;
}
}
if (memcpy_s(buffer_ + offset, bufferCapacity_ - static_cast<size_t>(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<size_t>(offset)) {
if (bufferSize_ == offset) {
bufferSize_ += length;
}
return res;
@ -207,7 +207,7 @@ public:
return RawDataEmit(reinterpret_cast<uint8_t *>(&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<uint8_t *>(&c), U64_SIZE, offset);
}

View File

@ -126,13 +126,13 @@ bool ValueSerializer::WriteValue(JSThread *thread,
for (auto &entry : detachCallbackInfo_) {
auto info = entry.second;
DetachFunc detachNative = reinterpret_cast<DetachFunc>(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<uint64_t>(buffer), entry.first);
data_->EmitU64(reinterpret_cast<uint64_t>(buffer), static_cast<size_t>(entry.first));
}
}
if (notSupport_) {