diff --git a/services/BUILD.gn b/services/BUILD.gn index ddc0b72b39ae7a5376d35939a94bb58bb16c4311..3e2f3a6856d89e4f3ae8110edc87fc061386ae0b 100755 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -127,6 +127,7 @@ ohos_static_library("libupdater_static") { config("libupdater_exported_headers") { visibility = [ ":*" ] include_dirs = [ + "${updater_path}/services/common", "${updater_path}/services/include", "${updater_path}/interfaces/kits/include", "${updater_path}/services", diff --git a/services/ptable_parse/ptable.cpp b/services/ptable_parse/ptable.cpp index d4f121d5420a9ce3a67997c5ea9ffd90a464b1b4..efb4572b84c8bfcc289eb9e9f546cec883a894b6 100644 --- a/services/ptable_parse/ptable.cpp +++ b/services/ptable_parse/ptable.cpp @@ -40,6 +40,12 @@ std::vector Ptable::GetPtablePartitionInfo() const return partitionInfo_; } +bool Ptable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, const std::vector &srcInfo, + const std::vector &dstInfo) +{ + return false; +} + uint32_t Ptable::GetPtablePartitionNum() const { return partitionInfo_.size(); diff --git a/services/ptable_parse/ptable.h b/services/ptable_parse/ptable.h index 0fc8c5dd5fc6942b81556e851d7782e41b48bc87..01a74a9506fbbbd0d69859abbb3ccc524cd2dc0f 100644 --- a/services/ptable_parse/ptable.h +++ b/services/ptable_parse/ptable.h @@ -67,10 +67,7 @@ public: virtual bool GetPtableImageBuffer(uint8_t *imageBuf, const uint32_t imgBufSize) = 0; virtual void AddChildPtable(std::unique_ptr child) {} virtual bool CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, const std::vector &srcInfo, - const std::vector &dstInfo) - { - return false; - } + const std::vector &dstInfo); int GetEndPtnIndex() { diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index 6ab0839a741876bef5866ae9ed9fba4193ff419c..856bb1abd739fcff44def61a965167a9c0b93b2c 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -196,8 +196,8 @@ void UfsPtable::UfsReadGptEntry(const uint8_t *gptImage, const uint32_t lun, typeGuid, sizeof(typeGuid)); newPtnInfo.isTailPart = tailPartFlag; newPtnInfo.lun = lun; - // 2 : pmbr and gpt header - newPtnInfo.gptEntryBufOffset = (partition0 + i) * blockSize + j * PARTITION_ENTRY_SIZE - 2 * blockSize; + newPtnInfo.gptEntryBufOffset = static_cast((partition0 + i) * blockSize + j * PARTITION_ENTRY_SIZE - + 2 * blockSize); // 2 : pmbr and gpt header if (newPtnInfo.dispName == USERDATA_PARTITION) { tailPartFlag = true; usrDataPtnIndex_ = std::distance(partitionInfo_.begin(), startIter); @@ -208,7 +208,7 @@ void UfsPtable::UfsReadGptEntry(const uint8_t *gptImage, const uint32_t lun, } if (tailPartFlag) { endPtnIndex_ = static_cast(std::distance(partitionInfo_.begin(), startIter)) - 1; - startPtnIndex_ = endPtnIndex_ + 1 - count; + startPtnIndex_ = endPtnIndex_ + 1 - static_cast(count); hasTailpart_ = partitionInfo_[endPtnIndex_].isTailPart; } return; @@ -528,13 +528,15 @@ uint8_t *UfsPtable::GetPtableImageUfsLunEntryStart(uint8_t *imageBuf, const uint bool UfsPtable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, const std::vector &srcInfo, const std::vector &dstInfo) { - if (imageBuf == nullptr || imgBufSize == 0 || srcInfo.size() != dstInfo.size()) { - LOG(ERROR) << "invalid input. imgBufSize : " << imgBufSize << " srcInfo.size: " << srcInfo.size() - << " dstInfo.size:" << dstInfo.size(); + int srcSize = static_cast(srcInfo.size()); + int dstSize = static_cast(dstInfo.size()); + if (imageBuf == nullptr || imgBufSize == 0 || srcSize != dstSize) { + LOG(ERROR) << "invalid input. imgBufSize : " << imgBufSize << " srcInfo.size: " << srcSize + << " dstInfo.size:" << dstSize; return false; } - if (usrDataPtnIndex_ < 0 || endPtnIndex_ < 0 || usrDataPtnIndex_ >= dstInfo.size() - || endPtnIndex_ >= dstInfo.size()) { + if (usrDataPtnIndex_ < 0 || endPtnIndex_ < 0 || usrDataPtnIndex_ >= dstSize || + endPtnIndex_ >= dstSize) { LOG(ERROR) << "invaild dst ptn info list"; return false; } @@ -552,7 +554,7 @@ bool UfsPtable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, cons PUT_LONG_LONG(newEntryBuf.data() + FIRST_LBA_OFFSET, dstInfo[i].startAddr / GetDeviceBlockSize()); PUT_LONG_LONG(newEntryBuf.data() + LAST_LBA_OFFSET, (dstInfo[i].startAddr + dstInfo[i].partitionSize) / GetDeviceBlockSize() - 1); - if (srcInfo[i].gptEntryBufOffset > editLen - PARTITION_ENTRY_SIZE) { + if (srcInfo[i].gptEntryBufOffset > static_cast(editLen - PARTITION_ENTRY_SIZE)) { LOG(ERROR) << "srcInfo[" << i << "] error. gptEntryBufOffset = " << srcInfo[i].gptEntryBufOffset; return false; }