Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15e98464 authored by Daniel Zheng's avatar Daniel Zheng
Browse files

isBlockAligned to use uint64_t

We want to avoid the usage of size_t for any integer value that could
exceed 2^32 (for 32 bit platforms). Let's update the usage here for
future compatibilty and avoid silent truncation failures.

Bug: 361048795
Test: th
Change-Id: I9ce2ca21706270a218f06f7d2b7dc9fade185a68
parent a7eb62c8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ class CowWriterV3 : public CowWriterBase {
                                                 CowOperationType type);
    size_t GetCompressionFactor(const size_t blocks_to_compress, CowOperationType type) const;

    constexpr bool IsBlockAligned(const size_t size) {
    constexpr bool IsBlockAligned(const uint64_t size) {
        // These are the only block size supported. Block size beyond 256k
        // may impact random read performance post OTA boot.
        const size_t values[] = {4_KiB, 8_KiB, 16_KiB, 32_KiB, 64_KiB, 128_KiB, 256_KiB};
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ class ReadWorker : public Worker, public IBlockServer::Delegate {
    bool ReadFromSourceDevice(const CowOperation* cow_op, void* buffer);
    bool ReadDataFromBaseDevice(sector_t sector, void* buffer, size_t read_size);

    constexpr bool IsBlockAligned(size_t size) { return ((size & (BLOCK_SZ - 1)) == 0); }
    constexpr bool IsBlockAligned(uint64_t size) { return ((size & (BLOCK_SZ - 1)) == 0); }
    constexpr sector_t ChunkToSector(chunk_t chunk) { return chunk << CHUNK_SHIFT; }
    constexpr chunk_t SectorToChunk(sector_t sector) { return sector >> CHUNK_SHIFT; }