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

Commit 98e21320 authored by Elliott Hughes's avatar Elliott Hughes Committed by Automerger Merge Worker
Browse files

FileMap::create: remove duplicate addition. am: 54794ac6 am: 2912d9c1

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12393457

Change-Id: I416cdeb24824e7da9f437f61530e1861c9ea446c
parents d05ecb8d 2912d9c1
Loading
Loading
Loading
Loading
+7 −14
Original line number Diff line number Diff line
@@ -168,12 +168,6 @@ bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t le
        return false;
    }
#else // !defined(__MINGW32__)
    int     prot, flags, adjust;
    off64_t adjOffset;
    size_t  adjLength;

    void* ptr;

    assert(fd >= 0);
    assert(offset >= 0);
    assert(length > 0);
@@ -187,20 +181,19 @@ bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t le
        }
    }

    adjust = offset % mPageSize;
    adjOffset = offset - adjust;
    adjLength = length + adjust;
    int adjust = offset % mPageSize;
    off64_t adjOffset = offset - adjust;
    size_t adjLength;
    if (__builtin_add_overflow(length, adjust, &adjLength)) {
        ALOGE("adjusted length overflow: length %zu adjust %d", length, adjust);
        return false;
    }

    flags = MAP_SHARED;
    prot = PROT_READ;
    if (!readOnly)
        prot |= PROT_WRITE;
    int flags = MAP_SHARED;
    int prot = PROT_READ;
    if (!readOnly) prot |= PROT_WRITE;

    ptr = mmap(NULL, adjLength, prot, flags, fd, adjOffset);
    void* ptr = mmap(nullptr, adjLength, prot, flags, fd, adjOffset);
    if (ptr == MAP_FAILED) {
        ALOGE("mmap(%lld,%zu) failed: %s\n",
            (long long)adjOffset, adjLength, strerror(errno));