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

Commit bd1d0fa3 authored by Ryan Prichard's avatar Ryan Prichard Committed by Automerger Merge Worker
Browse files

Merge "incfs: tolerate either ptrdiff_t or size_t for std::span" am:...

Merge "incfs: tolerate either ptrdiff_t or size_t for std::span" am: f93b1f96 am: 405237f2 am: 7dd0f616 am: 09c6bfec am: ed9022cd

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2202603



Change-Id: If7d53231c7317fb56d02379611e846aac4d02c8a
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents e7c495d6 ed9022cd
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -216,7 +216,10 @@ static std::span<const uint8_t> toSpan(const ::std::optional<::std::vector<uint8
    if (!content) {
    if (!content) {
        return {};
        return {};
    }
    }
    return {content->data(), (int)content->size()};
    // TODO(b/175635923): Replace with {content->data(), content->size()} after libc++ is upgraded.
    // The type of the second std::span ctor param changed from ptrdiff_t to size_t between the old
    // libc++ and the finalized C++20.
    return std::span<const uint8_t>(content->data(), content->size());
}
}


binder::Status BinderIncrementalService::makeFile(
binder::Status BinderIncrementalService::makeFile(
+3 −3
Original line number Original line Diff line number Diff line
@@ -1166,11 +1166,11 @@ int IncrementalService::makeFile(StorageId storage, std::string_view path, int m
    if (!ifs) {
    if (!ifs) {
        return -EINVAL;
        return -EINVAL;
    }
    }
    if (data.size() > params.size) {
    if ((IncFsSize)data.size() > params.size) {
        LOG(ERROR) << "Bad data size - bigger than file size";
        LOG(ERROR) << "Bad data size - bigger than file size";
        return -EINVAL;
        return -EINVAL;
    }
    }
    if (!data.empty() && data.size() != params.size) {
    if (!data.empty() && (IncFsSize)data.size() != params.size) {
        // Writing a page is an irreversible operation, and it can't be updated with additional
        // Writing a page is an irreversible operation, and it can't be updated with additional
        // data later. Check that the last written page is complete, or we may break the file.
        // data later. Check that the last written page is complete, or we may break the file.
        if (!isPageAligned(data.size())) {
        if (!isPageAligned(data.size())) {
@@ -3188,7 +3188,7 @@ binder::Status IncrementalService::IncrementalServiceConnector::setStorageParams
}
}


FileId IncrementalService::idFromMetadata(std::span<const uint8_t> metadata) {
FileId IncrementalService::idFromMetadata(std::span<const uint8_t> metadata) {
    return IncFs_FileIdFromMetadata({(const char*)metadata.data(), metadata.size()});
    return IncFs_FileIdFromMetadata({(const char*)metadata.data(), (IncFsSize)metadata.size()});
}
}


} // namespace android::incremental
} // namespace android::incremental