fix codereview

Signed-off-by: zhanghaibo <zhanghaibo0@huawei.com>
Change-Id: I6159fe5c2b64539cc77fbd90f05f452e0424d2be
This commit is contained in:
zhanghaibo
2022-03-22 15:07:50 +08:00
parent 7c4e62db8b
commit a601a9048b
4 changed files with 4 additions and 11 deletions
@@ -60,9 +60,6 @@ void JerryScriptNativeString::GetCString16(char16_t* buffer, size_t size, size_t
}
char *str = new char[utf8Length];
jerry_string_to_utf8_char_buffer(value_, (jerry_char_t*)str, utf8Length);
if (size < 0) {
return;
}
if (length != nullptr) {
*length = Utf8ToUtf16Length(str, utf8Length);
if (buffer != nullptr) {
@@ -64,10 +64,6 @@ void QuickJSNativeString::GetCString(char* buffer, size_t size, size_t* length)
}
void QuickJSNativeString::GetCString16(char16_t* buffer, size_t size, size_t* length)
{
if (size < 0) {
HILOG_ERROR("GetCString16 parameter is invalid");
return;
}
const char* str = JS_ToCStringLen(engine_->GetContext(), length, value_);
if (str == nullptr) {
HILOG_ERROR("JS_ToCStringLen return value is null");
@@ -58,7 +58,7 @@ void EventTarget::On(const char* type, napi_value handler)
{
auto tmp = new EventListener();
if (strncpy_s(tmp->type, LISTENER_TYPTE_MAX_LENGTH, type, strlen(type)) == -1) {
if (strncpy_s(tmp->type, LISTENER_TYPTE_MAX_LENGTH, type, strlen(type)) != EOK) {
delete tmp;
tmp = nullptr;
return;
@@ -79,7 +79,7 @@ void EventTarget::Once(const char* type, napi_value handler)
{
auto tmp = new EventListener();
if (strncpy_s(tmp->type, LISTENER_TYPTE_MAX_LENGTH, type, strlen(type)) == -1) {
if (strncpy_s(tmp->type, LISTENER_TYPTE_MAX_LENGTH, type, strlen(type)) != EOK) {
delete tmp;
tmp = nullptr;
return;
+2 -2
View File
@@ -277,8 +277,8 @@ static napi_value JSStorageGet(napi_env env, napi_callback_info info)
StorageAsyncContext* asyncContext = (StorageAsyncContext*)data;
auto itr = g_keyValueStorage.find(asyncContext->key);
if (itr != g_keyValueStorage.end()) {
if (strncpy_s(asyncContext->value, VALUE_BUFFER_SIZE, itr->second.c_str(), itr->second.length()) ==
-1) {
if (strncpy_s(asyncContext->value, VALUE_BUFFER_SIZE, itr->second.c_str(), itr->second.length()) !=
EOK) {
asyncContext->status = 1;
} else {
asyncContext->status = 0;