diff --git a/client/update_client.cpp b/client/update_client.cpp index 96880c3c60f31452d165d6d8124e62fd6e6a8d55..5ecaaec99b459a3e355db98825096bf9f1ebd48c 100644 --- a/client/update_client.cpp +++ b/client/update_client.cpp @@ -161,11 +161,11 @@ bool UpdateClient::CheckUpgradeFile(const std::string &upgradeFile) std::string file = upgradeFile; file.erase(0, file.find_first_not_of(" ")); file.erase(file.find_last_not_of(" ") + 1); - int32_t pos = file.find_first_of('/'); + int32_t pos = (int32_t)file.find_first_of('/'); if (pos != 0) { return false; } - pos = file.find_last_of('.'); + pos = (int32_t)file.find_last_of('.'); if (pos < 0) { return false; } @@ -791,7 +791,7 @@ int32_t UpdateClient::GetUpdatePolicyFromArg(napi_env env, // updatePolicy int32_t tmpValue = 0; - int32_t ret = GetBool(env, arg, "autoDownload", updatePolicy.autoDownload); + uint32_t ret = GetBool(env, arg, "autoDownload", updatePolicy.autoDownload); ret |= GetBool(env, arg, "autoDownloadNet", updatePolicy.autoDownloadNet); ret |= GetInt32(env, arg, "mode", tmpValue); updatePolicy.mode = static_cast(tmpValue); @@ -842,10 +842,10 @@ int32_t UpdateClient::BuildCheckVersionResult(napi_env env, napi_value &obj, con VersionInfo *info = result.result.versionInfo; // Add the result. - int32_t ret = SetInt32(env, obj, "status", info->status); + SetInt32(env, obj, "status", info->status); if (info->status == SERVER_BUSY || info->status == SYSTEM_ERROR) { - ret = SetString(env, obj, "errMsg", info->errMsg); - return ret; + SetString(env, obj, "errMsg", info->errMsg); + return CLIENT_SUCCESS; } napi_value checkResults; napi_create_array_with_length(env, sizeof(info->result) / sizeof(info->result[0]), &checkResults); @@ -853,12 +853,12 @@ int32_t UpdateClient::BuildCheckVersionResult(napi_env env, napi_value &obj, con napi_value result; status = napi_create_object(env, &result); - ret |= SetString(env, result, "versionName", info->result[i].versionName); - ret |= SetString(env, result, "versionCode", info->result[i].versionCode); - ret |= SetString(env, result, "verifyInfo", info->result[i].verifyInfo); - ret |= SetString(env, result, "descriptionId", info->result[i].descriptPackageId); - ret |= SetInt64(env, result, "size", info->result[i].size); - ret |= SetInt32(env, result, "packageType", info->result[i].packageType); + SetString(env, result, "versionName", info->result[i].versionName); + SetString(env, result, "versionCode", info->result[i].versionCode); + SetString(env, result, "verifyInfo", info->result[i].verifyInfo); + SetString(env, result, "descriptionId", info->result[i].descriptPackageId); + SetInt64(env, result, "size", info->result[i].size); + SetInt32(env, result, "packageType", info->result[i].packageType); napi_set_element(env, checkResults, i, result); } napi_set_named_property(env, obj, "checkResults", checkResults); @@ -868,8 +868,8 @@ int32_t UpdateClient::BuildCheckVersionResult(napi_env env, napi_value &obj, con for (size_t i = 0; i < sizeof(info->descriptInfo) / sizeof(info->descriptInfo[0]); i++) { napi_value descriptInfo; status = napi_create_object(env, &descriptInfo); - ret |= SetString(env, descriptInfo, "descriptionId", info->descriptInfo[i].descriptPackageId); - ret |= SetString(env, descriptInfo, "content", info->descriptInfo[i].content); + SetString(env, descriptInfo, "descriptionId", info->descriptInfo[i].descriptPackageId); + SetString(env, descriptInfo, "content", info->descriptInfo[i].content); napi_set_element(env, descriptInfos, i, descriptInfo); } napi_set_named_property(env, obj, "descriptionInfo", descriptInfos); @@ -881,9 +881,9 @@ int32_t UpdateClient::BuildProgress(napi_env env, napi_value &obj, const UpdateR napi_status status = napi_create_object(env, &obj); CLIENT_CHECK(status == napi_ok, return CLIENT_INVALID_TYPE, "Failed to create napi_create_object %d", static_cast(status)); - int32_t ret = SetInt32(env, obj, "status", result.result.progress->status); - ret |= SetInt32(env, obj, "percent", result.result.progress->percent); - ret |= SetString(env, obj, "endReason", result.result.progress->endReason); + SetInt32(env, obj, "status", result.result.progress->status); + SetInt32(env, obj, "percent", result.result.progress->percent); + SetString(env, obj, "endReason", result.result.progress->endReason); return CLIENT_SUCCESS; } @@ -909,10 +909,9 @@ int32_t UpdateClient::BuildUpdatePolicy(napi_env env, napi_value &obj, const Upd UpdatePolicy &updatePolicy = *result.result.updatePolicy; // Add the result. - int32_t ret = SetBool(env, obj, "autoDownload", updatePolicy.autoDownload); - ret |= SetBool(env, obj, "autoDownloadNet", updatePolicy.autoDownloadNet); - ret |= SetInt32(env, obj, "mode", static_cast(updatePolicy.mode)); - CLIENT_CHECK(ret == napi_ok, return ret, "Failed to add value %d", ret); + SetBool(env, obj, "autoDownload", updatePolicy.autoDownload); + SetBool(env, obj, "autoDownloadNet", updatePolicy.autoDownloadNet); + SetInt32(env, obj, "mode", static_cast(updatePolicy.mode)); napi_value autoUpgradeInterval; size_t count = sizeof(updatePolicy.autoUpgradeInterval) / sizeof(updatePolicy.autoUpgradeInterval[0]); @@ -926,8 +925,7 @@ int32_t UpdateClient::BuildUpdatePolicy(napi_env env, napi_value &obj, const Upd } status = napi_set_named_property(env, obj, "autoUpgradeInterval", autoUpgradeInterval); CLIENT_CHECK(status == napi_ok, return status, "Failed to add autoUpgradeInterval %d", status); - ret |= SetInt32(env, obj, "autoUpgradeCondition", static_cast(updatePolicy.autoUpgradeCondition)); - CLIENT_CHECK(ret == napi_ok, return ret, "Failed to add autoUpgradeCondition %d", ret); + SetInt32(env, obj, "autoUpgradeCondition", static_cast(updatePolicy.autoUpgradeCondition)); return napi_ok; } diff --git a/client/update_module.cpp b/client/update_module.cpp index 67c9663b0afbd7c9da2662adfc8a778f18ea80f4..3f8f9bebf75943ea607c331102e3d71882ca3c09 100644 --- a/client/update_module.cpp +++ b/client/update_module.cpp @@ -253,7 +253,7 @@ static napi_value UpdateClientInit(napi_env env, napi_value exports) napi_set_named_property(env, exports, CLASS_NAME.c_str(), result); napi_status status = napi_create_reference(env, result, REF_COUNT, &g_reference); CLIENT_CHECK_NAPI_CALL(env, status == napi_ok, return nullptr, "Failed to create_reference"); - CLIENT_LOGI("UpdateClient g_reference %p", g_reference); + CLIENT_LOGI("UpdateClient g_reference create success"); return exports; } diff --git a/client/update_session.cpp b/client/update_session.cpp index 0a2950c8023247cedd3f30f106525b35d3a571ab..0c3afaf701a6f9d689fdf0161ad1fa4eda3dc0d8 100644 --- a/client/update_session.cpp +++ b/client/update_session.cpp @@ -127,8 +127,8 @@ void UpdateAsyncession::CompleteWork(napi_env env, napi_status status) UpdateResult result; int32_t fail = 0; client_->GetUpdateResult(type_, result, fail); - int ret = UpdateClient::BuildErrorResult(env, retArgs[0], fail); - ret |= result.buildJSObject(env, retArgs[1], result); + uint32_t ret = (uint32_t)UpdateClient::BuildErrorResult(env, retArgs[0], fail); + ret |= (uint32_t)result.buildJSObject(env, retArgs[1], result); CLIENT_CHECK_NAPI_CALL(env, ret == napi_ok, return, "Failed to build json"); status = napi_get_reference_value(env, callbackRef_[0], &callback); diff --git a/engine/src/progress_thread.cpp b/engine/src/progress_thread.cpp index 6c1a11c5c3bfde61d5368fe649eb33fa1e51a9ec..d8a69ac463036b3112cd873ddbf4feedfd87f242 100755 --- a/engine/src/progress_thread.cpp +++ b/engine/src/progress_thread.cpp @@ -206,7 +206,7 @@ size_t DownloadThread::GetLocalFileLength(const std::string &fileName) FILE* fp = fopen(fileName.c_str(), "r"); ENGINE_CHECK_NO_LOG(fp != nullptr, return 0); fseek(fp, 0, SEEK_END); - size_t length = ftell(fp); + size_t length = (size_t)ftell(fp); fclose(fp); return length; } diff --git a/engine/src/update_service.cpp b/engine/src/update_service.cpp index 3d397c64604ba64ebe350f4578634083918b0f2e..62a2023278130524334b2ce76a9a5e099b2a63d2 100644 --- a/engine/src/update_service.cpp +++ b/engine/src/update_service.cpp @@ -75,7 +75,7 @@ UpdateService::UpdateService(int32_t systemAbilityId, bool runOnCreate) UpdateService::~UpdateService() { - ENGINE_LOGE("UpdateServerTest free %p", this); + ENGINE_LOGE("UpdateServerTest free now"); if (downloadThread_ != nullptr) { downloadThread_->StopDownload(); delete downloadThread_; @@ -352,7 +352,7 @@ int32_t UpdateService::ParseJsonFile(const std::vector &buffer, VersionInf int32_t UpdateService::ReadCheckVersionResult(const cJSON* results, VersionInfo &info) { - size_t number = cJSON_GetArraySize(results); + size_t number = (size_t)cJSON_GetArraySize(results); for (size_t i = 0; i < number && i < sizeof(info.result) / sizeof(info.result[0]); i++) { cJSON *result = cJSON_GetArrayItem(results, i); ENGINE_CHECK(result != nullptr, return -1, "Error get result"); @@ -371,7 +371,7 @@ int32_t UpdateService::ReadCheckVersionResult(const cJSON* results, VersionInfo item = cJSON_GetObjectItem(result, "size"); ENGINE_CHECK(item != nullptr, return -1, "Error get size"); - info.result[i].size = item->valueint; + info.result[i].size = (size_t)item->valueint; item = cJSON_GetObjectItem(result, "packageType"); ENGINE_CHECK(item != nullptr, return -1, "Error get packageType"); @@ -386,7 +386,7 @@ int32_t UpdateService::ReadCheckVersionResult(const cJSON* results, VersionInfo int32_t UpdateService::ReadCheckVersiondescriptInfo(const cJSON *descriptInfo, VersionInfo &info) { - size_t number = cJSON_GetArraySize(descriptInfo); + size_t number = (size_t)cJSON_GetArraySize(descriptInfo); for (size_t i = 0; i < number && i < sizeof(info.result) / sizeof(info.result[0]); i++) { cJSON* descript = cJSON_GetArrayItem(descriptInfo, i); ENGINE_CHECK(descript != nullptr, return -1, "Error get descriptInfo");