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

Commit c57cd3c5 authored by Harry Cutts's avatar Harry Cutts
Browse files

input: fix -Wformat warnings

These occur when an enum value is formatted as an integer without a
cast. In all these cases the debug logs are nicer if we use the actual
name of the enum value, so wrap them all in ftl::enum_string calls.

Bug: 245989146
Test: Check there are no -Wformat warnings in the output of
      $ m checkinput
Change-Id: I26333123e9fb445f1640c5e73757ddf4ad2d6e98
parent 8be72660
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -115,6 +115,8 @@ enum class InputDeviceSensorAccuracy : int32_t {
    ACCURACY_LOW = 1,
    ACCURACY_MEDIUM = 2,
    ACCURACY_HIGH = 3,

    ftl_last = ACCURACY_HIGH,
};

enum class InputDeviceSensorReportingMode : int32_t {
+7 −6
Original line number Diff line number Diff line
@@ -387,9 +387,9 @@ status_t InputChannel::openInputChannelPair(const std::string& name,

status_t InputChannel::sendMessage(const InputMessage* msg) {
    ATRACE_NAME_IF(ATRACE_ENABLED(),
                   StringPrintf("sendMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=0x%" PRIx32
                                ")",
                                name.c_str(), msg->header.seq, msg->header.type));
                   StringPrintf("sendMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=%s)",
                                name.c_str(), msg->header.seq,
                                ftl::enum_string(msg->header.type).c_str()));
    const size_t msgLength = msg->size();
    InputMessage cleanMsg;
    msg->getSanitizedCopy(&cleanMsg);
@@ -458,9 +458,10 @@ status_t InputChannel::receiveMessage(InputMessage* msg) {
             ftl::enum_string(msg->header.type).c_str());
    if (ATRACE_ENABLED()) {
        // Add an additional trace point to include data about the received message.
        std::string message = StringPrintf("receiveMessage(inputChannel=%s, seq=0x%" PRIx32
                                           ", type=0x%" PRIx32 ")",
                                           name.c_str(), msg->header.seq, msg->header.type);
        std::string message =
                StringPrintf("receiveMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=%s)",
                             name.c_str(), msg->header.seq,
                             ftl::enum_string(msg->header.type).c_str());
        ATRACE_NAME(message.c_str());
    }
    return OK;
+4 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@

#include <android-base/stringprintf.h>
#include <cutils/atomic.h>
#include <ftl/enum.h>
#include <inttypes.h>

using android::base::StringPrintf;
@@ -261,9 +262,10 @@ SensorEntry::SensorEntry(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32
std::string SensorEntry::getDescription() const {
    std::string msg;
    msg += StringPrintf("SensorEntry(deviceId=%d, source=%s, sensorType=%s, "
                        "accuracy=0x%08x, hwTimestamp=%" PRId64,
                        "accuracy=%s, hwTimestamp=%" PRId64,
                        deviceId, inputEventSourceToString(source).c_str(),
                        ftl::enum_string(sensorType).c_str(), accuracy, hwTimestamp);
                        ftl::enum_string(sensorType).c_str(), ftl::enum_string(accuracy).c_str(),
                        hwTimestamp);

    if (IS_DEBUGGABLE_BUILD) {
        for (size_t i = 0; i < values.size(); i++) {
+3 −1
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@

#include <sstream>

#include <ftl/enum.h>

#include "InputDevice.h"
#include "input/PrintTools.h"

@@ -133,7 +135,7 @@ void InputMapper::dumpStylusState(std::string& dump, const StylusState& state) {
    dump += StringPrintf(INDENT4 "When: %" PRId64 "\n", state.when);
    dump += StringPrintf(INDENT4 "Pressure: %s\n", toString(state.pressure).c_str());
    dump += StringPrintf(INDENT4 "Button State: 0x%08x\n", state.buttons);
    dump += StringPrintf(INDENT4 "Tool Type: %" PRId32 "\n", state.toolType);
    dump += StringPrintf(INDENT4 "Tool Type: %s\n", ftl::enum_string(state.toolType).c_str());
}

} // namespace android
+11 −7
Original line number Diff line number Diff line
@@ -1069,10 +1069,11 @@ void TouchInputMapper::configureInputDevice(nsecs_t when, bool* outResetNeeded)
    }

    if ((viewportChanged && !skipViewportUpdate) || deviceModeChanged) {
        ALOGI("Device reconfigured: id=%d, name='%s', size %s, orientation %d, mode %d, "
        ALOGI("Device reconfigured: id=%d, name='%s', size %s, orientation %s, mode %s, "
              "display id %d",
              getDeviceId(), getDeviceName().c_str(), toString(mDisplayBounds).c_str(),
              mInputDeviceOrientation, mDeviceMode, mViewport.displayId);
              ftl::enum_string(mInputDeviceOrientation).c_str(),
              ftl::enum_string(mDeviceMode).c_str(), mViewport.displayId);

        configureVirtualKeys();

@@ -1123,7 +1124,8 @@ void TouchInputMapper::dumpDisplay(std::string& dump) {
    dump += StringPrintf(INDENT3 "DisplayBounds: %s\n", toString(mDisplayBounds).c_str());
    dump += StringPrintf(INDENT3 "PhysicalFrameInRotatedDisplay: %s\n",
                         toString(mPhysicalFrameInRotatedDisplay).c_str());
    dump += StringPrintf(INDENT3 "InputDeviceOrientation: %d\n", mInputDeviceOrientation);
    dump += StringPrintf(INDENT3 "InputDeviceOrientation: %s\n",
                         ftl::enum_string(mInputDeviceOrientation).c_str());
}

void TouchInputMapper::configureVirtualKeys() {
@@ -3099,11 +3101,13 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when, bool* outCancelPrevi

    if (DEBUG_GESTURES) {
        ALOGD("Gestures: finishPreviousGesture=%s, cancelPreviousGesture=%s, "
              "currentGestureMode=%d, currentGestureIdBits=0x%08x, "
              "lastGestureMode=%d, lastGestureIdBits=0x%08x",
              "currentGestureMode=%s, currentGestureIdBits=0x%08x, "
              "lastGestureMode=%s, lastGestureIdBits=0x%08x",
              toString(*outFinishPreviousGesture), toString(*outCancelPreviousGesture),
              mPointerGesture.currentGestureMode, mPointerGesture.currentGestureIdBits.value,
              mPointerGesture.lastGestureMode, mPointerGesture.lastGestureIdBits.value);
              ftl::enum_string(mPointerGesture.currentGestureMode).c_str(),
              mPointerGesture.currentGestureIdBits.value,
              ftl::enum_string(mPointerGesture.lastGestureMode).c_str(),
              mPointerGesture.lastGestureIdBits.value);
        for (BitSet32 idBits = mPointerGesture.currentGestureIdBits; !idBits.isEmpty();) {
            uint32_t id = idBits.clearFirstMarkedBit();
            uint32_t index = mPointerGesture.currentGestureIdToIndex[id];
Loading