From 0655a874308b241a473cb9e2d5c57a35c66fb8dc Mon Sep 17 00:00:00 2001 From: chenzihan Date: Thu, 24 Mar 2022 19:10:21 +0800 Subject: [PATCH] Signed-off-by: chenzihan fix:codex warning fix --- services/applypatch/transfer_manager.cpp | 2 -- services/flashd/host/translate.cpp | 2 -- .../package/pkg_algorithm/pkg_algo_digest.cpp | 1 - services/package/pkg_package/pkg_upgradefile.cpp | 16 ++++++++-------- services/ui/text_label.cpp | 1 - services/updater_binary/update_image_block.cpp | 12 +++++++----- services/updater_binary/update_partitions.cpp | 3 ++- services/updater_binary/update_processor.cpp | 5 +++-- 8 files changed, 20 insertions(+), 22 deletions(-) diff --git a/services/applypatch/transfer_manager.cpp b/services/applypatch/transfer_manager.cpp index 6ba2e13d..f2281560 100644 --- a/services/applypatch/transfer_manager.cpp +++ b/services/applypatch/transfer_manager.cpp @@ -156,12 +156,10 @@ bool TransferManager::CheckResult(const CommandResult result, const std::string LOG(INFO) << "Running command need retry!"; UPDATER_CHECK_ONLY_RETURN(!globalParams->env, globalParams->env->PostMessage("retry_update", cmd)); return false; - break; case FAILED: default: LOG(ERROR) << "Running command failed"; return false; - break; } return true; } diff --git a/services/flashd/host/translate.cpp b/services/flashd/host/translate.cpp index dc7bc09d..a300c745 100755 --- a/services/flashd/host/translate.cpp +++ b/services/flashd/host/translate.cpp @@ -208,8 +208,6 @@ namespace TranslateCommand { TargetReboot(input.c_str(), outCmd); } else if (!strncmp(input.c_str(), CMDSTR_TARGET_MODE.c_str(), CMDSTR_TARGET_MODE.size())) { RunMode(input.c_str(), outCmd); - } else if (!strcmp(input.c_str(), CMDSTR_CONNECT_ANY.c_str())) { - outCmd->cmdFlag = CMD_KERNEL_TARGET_ANY; } else if (!strncmp(input.c_str(), CMDSTR_HILOG.c_str(), CMDSTR_HILOG.size())) { outCmd->cmdFlag = CMD_UNITY_HILOG; if (strstr(input.c_str(), " -v")) { diff --git a/services/package/pkg_algorithm/pkg_algo_digest.cpp b/services/package/pkg_algorithm/pkg_algo_digest.cpp index 0c1b8934..4bb6eef6 100644 --- a/services/package/pkg_algorithm/pkg_algo_digest.cpp +++ b/services/package/pkg_algorithm/pkg_algo_digest.cpp @@ -151,7 +151,6 @@ DigestAlgorithm::DigestAlgorithmPtr PkgAlgorithmFactory::GetDigestAlgorithm(uint return std::make_shared(); default: return std::make_shared(); - break; } return nullptr; } diff --git a/services/package/pkg_package/pkg_upgradefile.cpp b/services/package/pkg_package/pkg_upgradefile.cpp index 72e466ea..ecda48ae 100644 --- a/services/package/pkg_package/pkg_upgradefile.cpp +++ b/services/package/pkg_package/pkg_upgradefile.cpp @@ -129,10 +129,10 @@ int32_t UpgradePkgFile::SavePackage(size_t &signOffset) WriteLE32(reinterpret_cast(&header->updateFileVersion), pkgInfo_.updateFileVersion); int32_t ret = memcpy_s(header->softwareVersion, sizeof(header->softwareVersion), pkgInfo_.softwareVersion.data(), pkgInfo_.softwareVersion.size()); - PKG_CHECK(ret == EOK, return ret, "Fail to memcpy_s %s ret:%d", pkgStream_->GetFileName().c_str(), ret); + PKG_CHECK(ret == EOK, return ret, "Fail to memcpy_s %s ret: %d", pkgStream_->GetFileName().c_str(), ret); ret = memcpy_s(header->productUpdateId, sizeof(header->productUpdateId), pkgInfo_.productUpdateId.data(), pkgInfo_.productUpdateId.size()); - PKG_CHECK(ret == EOK, return ret, "Fail to memcpy_s %s ret:%d", pkgStream_->GetFileName().c_str(), ret); + PKG_CHECK(ret == EOK, return ret, "Fail to memcpy_s %s ret: %d", pkgStream_->GetFileName().c_str(), ret); offset += sizeof(UpgradePkgHeader); // 时间tlv WriteLE16(buffer.data() + offset, 0x02); // Type is 2 for time in TLV format @@ -140,16 +140,16 @@ int32_t UpgradePkgFile::SavePackage(size_t &signOffset) offset += sizeof(PkgTlv); UpgradePkgTime *time = reinterpret_cast(buffer.data() + offset); ret = memcpy_s(time->date, sizeof(time->date), pkgInfo_.date.data(), pkgInfo_.date.size()); - PKG_CHECK(ret == EOK, return ret, "Fail to memcpy_s %s ret:%d", pkgStream_->GetFileName().c_str(), ret); + PKG_CHECK(ret == EOK, return ret, "Fail to memcpy_s %s ret: %d", pkgStream_->GetFileName().c_str(), ret); ret = memcpy_s(time->time, sizeof(time->time), pkgInfo_.time.data(), pkgInfo_.time.size()); - PKG_CHECK(ret == EOK, return ret, "Fail to memcpy_s %s ret:%d", pkgStream_->GetFileName().c_str(), ret); + PKG_CHECK(ret == EOK, return ret, "Fail to memcpy_s %s ret: %d", pkgStream_->GetFileName().c_str(), ret); offset += sizeof(UpgradePkgTime); // 组件的tlv WriteLE16(buffer.data() + offset, 0x05); // Type is 5 for component in TLV format WriteLE16(buffer.data() + offset + sizeof(uint16_t), pkgInfo_.pkgInfo.entryCount * sizeof(UpgradeCompInfo)); offset += sizeof(PkgTlv); ret = pkgStream_->Write(buffer, UPGRADE_FILE_HEADER_LEN, 0); - PKG_CHECK(ret == PKG_SUCCESS, return ret, "Fail write upgrade file header for %s ret:%d", + PKG_CHECK(ret == PKG_SUCCESS, return ret, "Fail write upgrade file header for %s ret: %d", pkgStream_->GetFileName().c_str(), ret); // Clear buffer and save signature information @@ -374,7 +374,7 @@ int32_t UpgradeFileEntry::EncodeHeader(PkgStreamPtr inStream, size_t startOffset PKG_CHECK(ret == PKG_SUCCESS, return PKG_INVALID_PARAM, "outStream or inStream null for %s", fileName_.c_str()); ret = memcpy_s(comp.digest, sizeof(comp.digest), fileInfo_.digest, sizeof(fileInfo_.digest)); - PKG_CHECK(ret == EOK, return ret, "Fail to memcpy_s ret:%d", ret); + PKG_CHECK(ret == EOK, return ret, "Fail to memcpy_s ret: %d", ret); WriteLE32(reinterpret_cast(&comp.size), fileInfo_.fileInfo.unpackedSize); WriteLE16(reinterpret_cast(&comp.id), fileInfo_.id); WriteLE32(reinterpret_cast(&comp.originalSize), fileInfo_.originalSize); @@ -436,7 +436,7 @@ int32_t UpgradeFileEntry::DecodeHeader(const PkgBuffer &buffer, size_t headerOff fileInfo_.fileInfo.packMethod = PKG_COMPRESS_METHOD_NONE; fileInfo_.fileInfo.digestMethod = PKG_DIGEST_TYPE_NONE; int32_t ret = memcpy_s(fileInfo_.digest, sizeof(fileInfo_.digest), info->digest, sizeof(info->digest)); - PKG_CHECK(ret == EOK, return ret, "Fail to memcpy_s ret:%d", ret); + PKG_CHECK(ret == EOK, return ret, "Fail to memcpy_s ret: %d", ret); PkgFile::ConvertBufferToString(fileInfo_.fileInfo.identity, {info->address, sizeof(info->address)}); PkgFile::ConvertBufferToString(fileInfo_.version, {info->version, sizeof(info->version)}); fileName_ = fileInfo_.fileInfo.identity; @@ -468,7 +468,7 @@ int32_t UpgradeFileEntry::Unpack(PkgStreamPtr outStream) 0, fileInfo_.fileInfo.digestMethod }; int32_t ret = memcpy_s(context.digest, sizeof(context.digest), fileInfo_.digest, sizeof(fileInfo_.digest)); - PKG_CHECK(ret == EOK, return ret, "Fail to memcpy_s ret:%d", ret); + PKG_CHECK(ret == EOK, return ret, "Fail to memcpy_s ret: %d", ret); ret = algorithm->Unpack(inStream, outStream, context); PKG_CHECK(ret == PKG_SUCCESS, return ret, "Fail Decompress for %s", fileName_.c_str()); PKG_LOGI("Unpack %s data offset:%zu packedSize:%zu unpackedSize:%zu", fileName_.c_str(), dataOffset_, diff --git a/services/ui/text_label.cpp b/services/ui/text_label.cpp index d94a90a6..6037f3e1 100644 --- a/services/ui/text_label.cpp +++ b/services/ui/text_label.cpp @@ -37,7 +37,6 @@ TextLabel::TextLabel(int mStartX, int mStartY, int w, int h, Frame *mparent) outlineColor_.b = 0x00; outlineColor_.a = 0x00; boldTopLine_ = false; - boldTopLine_ = false; const char midAlpha = 0xAA; actionBgColor_.r = 0x00; diff --git a/services/updater_binary/update_image_block.cpp b/services/updater_binary/update_image_block.cpp index cd042792..32ff33b9 100644 --- a/services/updater_binary/update_image_block.cpp +++ b/services/updater_binary/update_image_block.cpp @@ -345,11 +345,11 @@ int32_t UScriptInstructionBlockCheck::Execute(uscript::UScriptEnv &env, uscript: LOG(INFO) << "BlockSet::ReadDataFromBlock lseek64"; ret = lseek64(fd, static_cast(it->first * H_BLOCK_SIZE), SEEK_SET); UPDATER_ERROR_CHECK(ret != -1, "Failed to seek", - return ReturnAndPushParam(USCRIPT_ERROR_EXECUTE, context)); + close(fd); return ReturnAndPushParam(USCRIPT_ERROR_EXECUTE, context)); size_t size = (it->second - it->first) * H_BLOCK_SIZE; LOG(INFO) << "BlockSet::ReadDataFromBlock Read " << size << " from block"; UPDATER_ERROR_CHECK(utils::ReadFully(fd, block_buff.data() + pos, size), "Failed to read", - return ReturnAndPushParam(USCRIPT_ERROR_EXECUTE, context)); + close(fd); return ReturnAndPushParam(USCRIPT_ERROR_EXECUTE, context)); pos += size; } @@ -365,6 +365,7 @@ int32_t UScriptInstructionBlockCheck::Execute(uscript::UScriptEnv &env, uscript: } LOG(INFO) << "UScriptInstructionBlockCheck::Execute Success"; context.PushParam(USCRIPT_SUCCESS); + close(fd); return USCRIPT_SUCCESS; } @@ -405,11 +406,11 @@ int32_t UScriptInstructionShaCheck::Execute(uscript::UScriptEnv &env, uscript::U for (; it != blk.End(); ++it) { ret = lseek64(fd, static_cast(it->first * H_BLOCK_SIZE), SEEK_SET); UPDATER_ERROR_CHECK(ret != -1, "Failed to seek", - return ReturnAndPushParam(USCRIPT_ERROR_EXECUTE, context)); + close(fd); return ReturnAndPushParam(USCRIPT_ERROR_EXECUTE, context)); for (size_t i = it->first; i < it->second; ++i) { UPDATER_ERROR_CHECK(utils::ReadFully(fd, block_buff.data(), H_BLOCK_SIZE), "Failed to read", - return ReturnAndPushParam(USCRIPT_ERROR_EXECUTE, context)); + close(fd); return ReturnAndPushParam(USCRIPT_ERROR_EXECUTE, context)); SHA256_Update(&ctx, block_buff.data(), H_BLOCK_SIZE); } } @@ -417,9 +418,10 @@ int32_t UScriptInstructionShaCheck::Execute(uscript::UScriptEnv &env, uscript::U SHA256_Final(digest, &ctx); std::string resultSha = utils::ConvertSha256Hex(digest, SHA256_DIGEST_LENGTH); UPDATER_ERROR_CHECK(resultSha == contrastSha, "Different sha256, cannot continue", - return ReturnAndPushParam(USCRIPT_ERROR_EXECUTE, context)); + close(fd); return ReturnAndPushParam(USCRIPT_ERROR_EXECUTE, context)); LOG(INFO) << "UScriptInstructionShaCheck::Execute Success"; context.PushParam(USCRIPT_SUCCESS); + close(fd); return USCRIPT_SUCCESS; } } diff --git a/services/updater_binary/update_partitions.cpp b/services/updater_binary/update_partitions.cpp index edd7fcab..89c13a31 100644 --- a/services/updater_binary/update_partitions.cpp +++ b/services/updater_binary/update_partitions.cpp @@ -117,7 +117,8 @@ int32_t UpdatePartitions::Execute(uscript::UScriptEnv &env, uscript::UScriptCont std::string tmpPath1 = tmpPath + filePath; ret = env.GetPkgManager()->CreatePkgStream(outStream, tmpPath1, info->unpackedSize, PkgStream::PkgStreamType_Write); - UPDATER_ERROR_CHECK(outStream != nullptr, "Error to create output stream", return USCRIPT_ERROR_EXECUTE); + UPDATER_ERROR_CHECK(ret == USCRIPT_SUCCESS && outStream != nullptr, "Error to create output stream", + return USCRIPT_ERROR_EXECUTE); ret = env.GetPkgManager()->ExtractFile(filePath, outStream); UPDATER_ERROR_CHECK(ret == USCRIPT_SUCCESS, "Error to extract file", env.GetPkgManager()->ClosePkgStream(outStream); return USCRIPT_ERROR_EXECUTE); diff --git a/services/updater_binary/update_processor.cpp b/services/updater_binary/update_processor.cpp index 34675148..8bcc08c0 100644 --- a/services/updater_binary/update_processor.cpp +++ b/services/updater_binary/update_processor.cpp @@ -146,7 +146,7 @@ int32_t UScriptInstructionRawImageWrite::Execute(uscript::UScriptEnv &env, uscri totalSize_ = info->unpackedSize; ret = env.GetPkgManager()->CreatePkgStream(outStream, imageFilename, RawImageWriteProcessor, writer.get()); - UPDATER_ERROR_CHECK(outStream != nullptr, "Error to create output stream", + UPDATER_ERROR_CHECK(ret == USCRIPT_SUCCESS && outStream != nullptr, "Error to create output stream", DataWriter::ReleaseDataWriter(writer); return USCRIPT_ERROR_EXECUTE); ret = env.GetPkgManager()->ExtractFile(imageFilename, outStream); @@ -187,7 +187,8 @@ int32_t UScriptInstructionSparseImageWrite::Execute(uscript::UScriptEnv &env, us ret = env.GetPkgManager()->CreatePkgStream(outStream, partitionName, info->unpackedSize, PkgStream::PkgStreamType_MemoryMap); - UPDATER_ERROR_CHECK(outStream != nullptr, "Error to create output stream", return USCRIPT_ERROR_EXECUTE); + UPDATER_ERROR_CHECK(ret == USCRIPT_SUCCESS && outStream != nullptr, "Error to create output stream", + return USCRIPT_ERROR_EXECUTE); ret = env.GetPkgManager()->ExtractFile(partitionName, outStream); UPDATER_ERROR_CHECK(ret == USCRIPT_SUCCESS, "Error to extract file", -- Gitee