Make 'image_offset' unsigned Since 'image_offset' represents a file offset, it is always unsigned. Make its type unsigned to prevent that a cast has to be introduced in the next patch when assigning an image offset to the 'lo_offset' member. Bug: 194450129 Test: Built Android images and installed these on an Android phone. Change-Id: I884d91647669560148c5f62cef68633b1a8c7a7d Signed-off-by: Bart Van Assche <[email protected]>
diff --git a/apexd/apex_file.cpp b/apexd/apex_file.cpp index 152e580..91be4a2 100644 --- a/apexd/apex_file.cpp +++ b/apexd/apex_file.cpp
@@ -62,7 +62,7 @@ constexpr const FsMagic kFsType[] = {{"f2fs", 1024, 4, "\x10\x20\xf5\xf2"}, {"ext4", 1024 + 0x38, 2, "\123\357"}}; -Result<std::string> RetrieveFsType(borrowed_fd fd, int32_t image_offset) { +Result<std::string> RetrieveFsType(borrowed_fd fd, uint32_t image_offset) { for (const auto& fs : kFsType) { char buf[fs.len]; if (!ReadFullyAtOffset(fd, buf, fs.len, image_offset + fs.offset)) { @@ -78,7 +78,7 @@ } // namespace Result<ApexFile> ApexFile::Open(const std::string& path) { - std::optional<int32_t> image_offset; + std::optional<uint32_t> image_offset; std::optional<size_t> image_size; std::string manifest_content; std::string pubkey;