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

Commit b4aca6c7 authored by Neill Kapron's avatar Neill Kapron
Browse files

libtimeinstate: fix unused variable warning



Move busy loop variable to static scope in the test and add used
attribute. This silences the unused variable warning when
building.

Test: manual
Change-Id: I56c7bccfd7a9ee5a2e530b220999c364ec8733c0
Signed-off-by: default avatarNeill Kapron <nkapron@google.com>
parent cf2f81a8
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -40,6 +40,9 @@ namespace bpf {
static constexpr uint64_t NSEC_PER_SEC = 1000000000;
static constexpr uint64_t NSEC_PER_SEC = 1000000000;
static constexpr uint64_t NSEC_PER_YEAR = NSEC_PER_SEC * 60 * 60 * 24 * 365;
static constexpr uint64_t NSEC_PER_YEAR = NSEC_PER_SEC * 60 * 60 * 24 * 365;


// Declare busy loop variable globally to prevent removal during optimization
static long sum __attribute__((used)) = 0;

using std::vector;
using std::vector;


class TimeInStateTest : public testing::Test {
class TimeInStateTest : public testing::Test {
@@ -576,7 +579,7 @@ uint64_t timeNanos() {


// Keeps CPU busy with some number crunching
// Keeps CPU busy with some number crunching
void useCpu() {
void useCpu() {
    long sum = 0;
    sum = 0;
    for (int i = 0; i < 100000; i++) {
    for (int i = 0; i < 100000; i++) {
        sum *= i;
        sum *= i;
    }
    }