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

Commit 20a9eff0 authored by Ryan Prichard's avatar Ryan Prichard Committed by Android (Google) Code Review
Browse files

Merge changes If07936bd,I5e6f973d into main

* changes:
  Rename ExtendedAccumulator::Wrap enumerators
  media/ndk: add missing <functional> includes
parents a8bcd631 f93ae78c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
#include <NdkMediaCodecFuzzerBase.h>
#include <media/NdkMediaFormatPriv.h>
#include <functional>
#include <mutex>
#include <queue>
#include <thread>
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#include <fuzzer/FuzzedDataProvider.h>
#include <media/NdkMediaCrypto.h>
#include <functional>

constexpr size_t kMaxString = 256;
constexpr size_t kMinBytes = 0;
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <fuzzer/FuzzedDataProvider.h>
#include <gui/BufferQueue.h>
#include <media/NdkImageReader.h>
#include <functional>

constexpr int32_t kMaxSize = INT_MAX;
constexpr int32_t kMinSize = 1;
+5 −5
Original line number Diff line number Diff line
@@ -48,9 +48,9 @@ class ExtendedAccumulator {

  public:
    enum class Wrap {
        NORMAL = 0,
        UNDERFLOW = 1,
        OVERFLOW = 2,
        Normal = 0,
        Underflow = 1,
        Overflow = 2,
    };

    using UnsignedInt = Integral;
@@ -63,11 +63,11 @@ class ExtendedAccumulator {
    std::pair<SignedInt, Wrap> poll(UnsignedInt value) {
        auto acc = mAccumulated.load(std::memory_order_relaxed);
        const auto bottom_bits = static_cast<UnsignedInt>(acc);
        std::pair<SignedInt, Wrap> res = {0, Wrap::NORMAL};
        std::pair<SignedInt, Wrap> res = {0, Wrap::Normal};
        const bool overflow = __builtin_sub_overflow(value, bottom_bits, &res.first);

        if (overflow) {
            res.second = (res.first > 0) ? Wrap::OVERFLOW : Wrap::UNDERFLOW;
            res.second = (res.first > 0) ? Wrap::Overflow : Wrap::Underflow;
        }

        const bool acc_overflow = __builtin_add_overflow(acc, res.first, &acc);
+3 −3
Original line number Diff line number Diff line
@@ -68,10 +68,10 @@ void testPair(TestUInt prevVal, std::make_signed_t<TestUInt> delta) {
    EXPECT_EQ(result, delta);

    // Test overflow/underflow event reporting.
    if (next < base) EXPECT_EQ(TestDetect::Wrap::UNDERFLOW, status);
    if (next < base) EXPECT_EQ(TestDetect::Wrap::Underflow, status);
    else if (next > base + std::numeric_limits<TestUInt>::max())
        EXPECT_EQ(TestDetect::Wrap::OVERFLOW, status);
    else EXPECT_EQ(TestDetect::Wrap::NORMAL, status);
        EXPECT_EQ(TestDetect::Wrap::Overflow, status);
    else EXPECT_EQ(TestDetect::Wrap::Normal, status);
}

// Test this utility on every combination of prior and update value for the