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

Commit 750c7f4b authored by Garfield Tan's avatar Garfield Tan
Browse files

Avoid shifting 1s into size bit.

Shifting 1 into size bit of sized integers is undefined until C++20, so
let's avoid undefined behavior.

Bug: None
Test: Event ID in systrace seems to bear correct source bits.
Change-Id: Id2ef5dc05a744476a713a111678dea966f1a5e32
parent 28f3700d
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -280,9 +280,9 @@ private:
public:
    // Used to divide integer space to ensure no conflict among these sources./
    enum class Source : int32_t {
        INPUT_READER = 0x0 << SOURCE_SHIFT,
        INPUT_DISPATCHER = 0x1 << SOURCE_SHIFT,
        OTHER = 0x3 << SOURCE_SHIFT, // E.g. app injected events
        INPUT_READER = static_cast<int32_t>(0x0u << SOURCE_SHIFT),
        INPUT_DISPATCHER = static_cast<int32_t>(0x1u << SOURCE_SHIFT),
        OTHER = static_cast<int32_t>(0x3u << SOURCE_SHIFT), // E.g. app injected events
    };
    IdGenerator(Source source);

@@ -294,7 +294,7 @@ public:
private:
    const Source mSource;

    static constexpr int32_t SOURCE_MASK = 0x3 << SOURCE_SHIFT;
    static constexpr int32_t SOURCE_MASK = static_cast<int32_t>(0x3u << SOURCE_SHIFT);
};

/**