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

Commit 91c4cd51 authored by Michael Wright's avatar Michael Wright Committed by Elliott Hughes
Browse files

Always initialize local boolean variables when possible

It's currently possible to reference deviceModeChanged in InputReader
while it's in an unknown state. Change the style of initialization
here and a few other places to better prevent this type of error.

(cherry-pick of f583d0dc.)

Bug: 11433748
Change-Id: Ic450ca4afe50987b022db9d20bb1cb18ccf060cc
parent 69920427
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -2133,12 +2133,11 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t keyCode,
        }
    }

    bool metaStateChanged = false;
    int32_t oldMetaState = mMetaState;
    int32_t newMetaState = updateMetaState(keyCode, down, oldMetaState);
    if (oldMetaState != newMetaState) {
    bool metaStateChanged = oldMetaState != newMetaState;
    if (metaStateChanged) {
        mMetaState = newMetaState;
        metaStateChanged = true;
        updateLedState(false);
    }

@@ -2926,7 +2925,6 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
    int32_t rawHeight = mRawPointerAxes.y.maxValue - mRawPointerAxes.y.minValue + 1;

    // Get associated display dimensions.
    bool viewportChanged = false;
    DisplayViewport newViewport;
    if (mParameters.hasAssociatedDisplay) {
        if (!mConfig.getDisplayInfo(mParameters.associatedDisplayIsExternal, &newViewport)) {
@@ -2940,9 +2938,9 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
    } else {
        newViewport.setNonDisplayViewport(rawWidth, rawHeight);
    }
    if (mViewport != newViewport) {
    bool viewportChanged = mViewport != newViewport;
    if (viewportChanged) {
        mViewport = newViewport;
        viewportChanged = true;

        if (mDeviceMode == DEVICE_MODE_DIRECT || mDeviceMode == DEVICE_MODE_POINTER) {
            // Convert rotated viewport to natural surface coordinates.
@@ -3011,9 +3009,8 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
    }

    // If moving between pointer modes, need to reset some state.
    bool deviceModeChanged;
    if (mDeviceMode != oldDeviceMode) {
        deviceModeChanged = true;
    bool deviceModeChanged = mDeviceMode != oldDeviceMode;
    if (deviceModeChanged) {
        mOrientedRanges.clear();
    }