From e6b233c2c4dfa536317e3feef4da8985c5f69d36 Mon Sep 17 00:00:00 2001 From: lizhao Date: Tue, 31 Dec 2024 10:58:11 +0800 Subject: [PATCH 1/5] fix codex Signed-off-by: lizhao --- services/BUILD.gn | 1 + services/ptable_parse/ptable.cpp | 6 ++++++ services/ptable_parse/ptable.h | 5 +---- services/ptable_parse/ufs_ptable.cpp | 14 ++++++++------ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/services/BUILD.gn b/services/BUILD.gn index ddc0b72b..3e2f3a68 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 d4f121d5..efb4572b 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 0fc8c5dd..01a74a95 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 6ab0839a..3c9dc31f 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -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; } -- Gitee From 64651d97bac35ae420c2c9b4d058738a72176142 Mon Sep 17 00:00:00 2001 From: lizhao Date: Tue, 31 Dec 2024 14:29:24 +0800 Subject: [PATCH 2/5] fix Signed-off-by: lizhao --- services/ptable_parse/ufs_ptable.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index 3c9dc31f..6289e30a 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -535,8 +535,8 @@ bool UfsPtable::CorrectBufByPtnList(uint8_t *imageBuf, uint64_t imgBufSize, cons << " dstInfo.size:" << dstSize; return false; } - if (usrDataPtnIndex_ < 0 || endPtnIndex_ < 0 || usrDataPtnIndex_ >= dstSize - || endPtnIndex_ >= dstSize) { + if (usrDataPtnIndex_ < 0 || endPtnIndex_ < 0 || usrDataPtnIndex_ >= dstSize || + endPtnIndex_ >= dstSize) { LOG(ERROR) << "invaild dst ptn info list"; return false; } -- Gitee From 61b14d624cc87cae3495941a1d2c1d4b3d6ed977 Mon Sep 17 00:00:00 2001 From: lizhao Date: Thu, 2 Jan 2025 21:36:25 +0800 Subject: [PATCH 3/5] fix codex Signed-off-by: lizhao --- services/ptable_parse/ufs_ptable.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index 6289e30a..22cf56d4 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -197,7 +197,7 @@ void UfsPtable::UfsReadGptEntry(const uint8_t *gptImage, const uint32_t lun, 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); 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; -- Gitee From 9fa315c45026cf1f139512e77d48d2406b0a099b Mon Sep 17 00:00:00 2001 From: lizhao Date: Thu, 2 Jan 2025 21:38:55 +0800 Subject: [PATCH 4/5] fix codex Signed-off-by: lizhao --- services/ptable_parse/ufs_ptable.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index 22cf56d4..00870735 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -197,7 +197,8 @@ void UfsPtable::UfsReadGptEntry(const uint8_t *gptImage, const uint32_t lun, newPtnInfo.isTailPart = tailPartFlag; newPtnInfo.lun = lun; // 2 : pmbr and gpt header - newPtnInfo.gptEntryBufOffset = static_cast((partition0 + i) * blockSize + j * PARTITION_ENTRY_SIZE - 2 * blockSize); + newPtnInfo.gptEntryBufOffset = static_cast((partition0 + i) * blockSize + + j * PARTITION_ENTRY_SIZE - 2 * blockSize); if (newPtnInfo.dispName == USERDATA_PARTITION) { tailPartFlag = true; usrDataPtnIndex_ = std::distance(partitionInfo_.begin(), startIter); -- Gitee From 51f0f4fc7423ee50e50124fabf2adff4a7dabde5 Mon Sep 17 00:00:00 2001 From: lizhao Date: Thu, 2 Jan 2025 21:51:45 +0800 Subject: [PATCH 5/5] fix Signed-off-by: lizhao --- services/ptable_parse/ufs_ptable.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/services/ptable_parse/ufs_ptable.cpp b/services/ptable_parse/ufs_ptable.cpp index 00870735..856bb1ab 100644 --- a/services/ptable_parse/ufs_ptable.cpp +++ b/services/ptable_parse/ufs_ptable.cpp @@ -196,9 +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 = static_cast((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); -- Gitee