Skip to content

Commit

Permalink
chore: Fix infer code warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-TU authored and pktiuk committed Oct 11, 2022
1 parent 35c0089 commit a2dc31c
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/eventhandlers/uinputeventhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void UInputEventHandler::sendMouseButtonEvent(JoyButtonSlot *slot, bool pressed)
{
if (code <= 3)
{
unsigned int tempcode = BTN_LEFT;
unsigned int tempcode;
switch (code)
{
case 3: {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/advancebuttondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ void AdvanceButtonDialog::updateSetSelection()
{
PadderCommon::inputDaemonMutex.lock();

int chosen_set = -1;
int chosen_set;
JoyButton::SetChangeCondition set_selection_condition = JoyButton::SetChangeDisabled;

if (ui->setSelectionComboBox->currentIndex() > 0)
Expand Down
14 changes: 10 additions & 4 deletions src/inputdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,11 +600,17 @@ void InputDevice::changeSetAxisButtonAssociation(int button_index, int axis_inde
} else if (button_index == 1)
{
button = getJoystick_sets().value(newset)->getJoyAxis(axis_index)->getPAxisButton();
} else
{
WARN() << "Invalid button_index value: " << button_index;
return;
}
if (button != nullptr)
{
JoyButton::SetChangeCondition tempmode = static_cast<JoyButton::SetChangeCondition>(mode);
button->setChangeSetSelection(originset);
button->setChangeSetCondition(tempmode, true);
}

JoyButton::SetChangeCondition tempmode = static_cast<JoyButton::SetChangeCondition>(mode);
button->setChangeSetSelection(originset);
button->setChangeSetCondition(tempmode, true);
}

void InputDevice::changeSetStickButtonAssociation(int button_index, int stick_index, int originset, int newset, int mode)
Expand Down
11 changes: 4 additions & 7 deletions src/joybutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ void JoyButton::mouseEvent()

// Determine the multiplier to use for the current maximum mouse speed
// based on how much time has passed.
double elapsedDiff = 1.0;
double elapsedDiff;
if ((easingDuration > 0.0) && ((easingElapsed * .001) < easingDuration))
{
elapsedDiff = ((easingElapsed * .001) / easingDuration);
Expand Down Expand Up @@ -1291,7 +1291,7 @@ void JoyButton::mouseEvent()
}

double tempAccel = currentAccelMultiTemp;
double elapsedDiff = 1.0;
double elapsedDiff;

if ((elapsedDuration > 0.0) && ((elapsedElapsed * 0.001) < elapsedDuration))
{
Expand All @@ -1305,7 +1305,6 @@ void JoyButton::mouseEvent()
updateOldAccelMulti = currentAccelMulti;
} else
{
elapsedDiff = 1.0;
currentAccelMulti = 0.0;
updateOldAccelMulti = 0.0;
accelTravel = 0.0;
Expand Down Expand Up @@ -3801,8 +3800,6 @@ void JoyButton::moveSpringMouse(int &movedX, int &movedY, bool &hasMoved, int sp

for (int i = (springXSpeeds->length() - 1); (i >= 0) && !complete; i--)
{
double tempx = -2.0;
double tempy = -2.0;
double tempSpringDeadX = 0.0;
double tempSpringDeadY = 0.0;

Expand All @@ -3812,8 +3809,8 @@ void JoyButton::moveSpringMouse(int &movedX, int &movedY, bool &hasMoved, int sp
infoX = springXSpeeds->takeLast();
infoY = springYSpeeds->takeLast();

tempx = infoX.displacementX;
tempy = infoY.displacementY;
double tempx = infoX.displacementX;
double tempy = infoY.displacementY;
tempSpringDeadX = infoX.springDeadX;
tempSpringDeadY = infoY.springDeadY;

Expand Down
3 changes: 1 addition & 2 deletions src/joycontrolstick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1985,15 +1985,14 @@ bool JoyControlStick::hasSameButtonsMouseCurve()
{
bool result = true;

JoyButton::JoyMouseCurve initialCurve = JoyButton::LinearCurve;
QHash<JoyStickDirections, JoyControlStickButton *> temphash = getApplicableButtons();
auto iter = temphash.cbegin();

if (iter == temphash.cend())
return result;

JoyControlStickButton *button = iter.value();
initialCurve = button->getMouseCurve();
JoyButton::JoyMouseCurve initialCurve = button->getMouseCurve();

while (++iter != temphash.cend())
{
Expand Down
4 changes: 1 addition & 3 deletions src/joydpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,14 @@ bool JoyDPad::hasSameButtonsMouseCurve()
{
bool result = true;

JoyButton::JoyMouseCurve initialCurve = JoyButton::LinearCurve;

QHash<int, JoyDPadButton *> temphash = getApplicableButtons();
auto iter = temphash.cbegin();

if (iter == temphash.cend())
return result;

JoyDPadButton *button = iter.value();
initialCurve = button->getMouseCurve();
JoyButton::JoyMouseCurve initialCurve = button->getMouseCurve();

while (++iter != temphash.cend())
{
Expand Down
2 changes: 1 addition & 1 deletion src/mousedialog/springmoderegionpreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int SpringModeRegionPreview::adjustSpringSizeWidth(int width)

int SpringModeRegionPreview::adjustSpringSizeHeight(int height)
{
int tempheight = size().height();
int tempheight;

if (height >= 2)
{
Expand Down
4 changes: 1 addition & 3 deletions src/x11extras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ QString X11Extras::getWindowClass(Window window)
qDebug() << nitems;

char *null_char = strchr(reinterpret_cast<char *>(prop), '\0');
if (((reinterpret_cast<char *>(prop)) + nitems - 1) > null_char)
if ((null_char != nullptr) && (((reinterpret_cast<char *>(prop)) + nitems - 1) > null_char))
{
*(null_char) = ' ';
}
Expand Down Expand Up @@ -654,7 +654,6 @@ void X11Extras::x11ResetMouseAccelerationChange(QString pointerName)
checkFeedback(temp, num_feedbacks, feedback_id);

XFree(feedbacks);
feedbacks = temp = nullptr;

if (feedback_id <= -1)
{
Expand Down Expand Up @@ -750,7 +749,6 @@ struct X11Extras::ptrInformation X11Extras::getPointInformation(QString pointerN
}

XFree(feedbacks);
feedbacks = temp = nullptr;
XCloseDevice(display, device);
}

Expand Down
1 change: 0 additions & 1 deletion src/xml/joybuttonslotxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ void JoyButtonSlotXml::readConfig(QXmlStreamReader *xml)
tempStringData = QString();
extraStringData = QString();
slotMixString = QString();
firstTimePlus = true;

xml->readNextStartElement();
}
Expand Down

0 comments on commit a2dc31c

Please sign in to comment.