Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIx warnings and problems detected by Infer code analysis #557

Closed
pktiuk opened this issue Oct 10, 2022 · 2 comments · Fixed by #558
Closed

FIx warnings and problems detected by Infer code analysis #557

pktiuk opened this issue Oct 10, 2022 · 2 comments · Fixed by #558
Assignees
Labels
good first issue Good for newcomers low-priotity refactor Issues connected with cleaning-up repository

Comments

@pktiuk
Copy link
Member

pktiuk commented Oct 10, 2022

Static code analysis from our CI ( Static Code Analysis) detected some warnings which should be fixed.

Report
#0
src/xml/joybuttonslotxml.cpp:129: error: Dead Store
The value written to &firstTimePlus (type _Bool) is never used.
127.                 extraStringData = QString();
128.                 slotMixString = QString();
129.                 firstTimePlus = true;
                     ^
130. 
131.                 xml->readNextStartElement();

#1
src/xml/inputdevicexml.cpp:249: error: Dead Store
The value written to &direction (type int) is never used.
247.                     {
248.                         int type = xml->attributes().value("type").toString().toInt();
249.                         int direction = xml->attributes().value("button").toString().toInt();
                             ^
250.                         QString temp = xml->readElementText();
251.                         if (!temp.isEmpty())

#2
src/xml/inputdevicexml.cpp:248: error: Dead Store
The value written to &type (type int) is never used.
246.                     } else if ((xml->name() == "sensorbuttonname") && xml->isStartElement())
247.                     {
248.                         int type = xml->attributes().value("type").toString().toInt();
                             ^
249.                         int direction = xml->attributes().value("button").toString().toInt();
250.                         QString temp = xml->readElementText();

#3
src/xml/inputdevicexml.cpp:298: error: Dead Store
The value written to &type (type int) is never used.
296.                     } else if ((xml->name() == "sensorname") && xml->isStartElement())
297.                     {
298.                         int type = xml->attributes().value("type").toString().toInt();
                             ^
299.                         QString temp = xml->readElementText();
300.                         if (!temp.isEmpty())

#4
src/mousedialog/springmoderegionpreview.cpp:74: error: Dead Store
The value written to &tempwidth (type int) is never used.
72. int SpringModeRegionPreview::adjustSpringSizeWidth(int width)
73. {
74.     int tempwidth = size().width();
        ^
75.     if (width >= 2)
76.     {

#5
src/mousedialog/springmoderegionpreview.cpp:88: error: Dead Store
The value written to &tempheight (type int) is never used.
86. int SpringModeRegionPreview::adjustSpringSizeHeight(int height)
87. {
88.     int tempheight = size().height();
        ^
89. 
90.     if (height >= 2)

#6
src/eventhandlers/uinputeventhandler.cpp:197: error: Dead Store
The value written to &tempcode (type unsigned int) is never used.
195.         if (code <= 3)
196.         {
197.             unsigned int tempcode = BTN_LEFT;
                 ^
198.             switch (code)
199.             {

#7
src/joydpad.cpp:319: error: Dead Store
The value written to &initialCurve (type int) is never used.
317.     bool result = true;
318. 
319.     JoyButton::JoyMouseCurve initialCurve = JoyButton::LinearCurve;
         ^
320. 
321.     QHash<int, JoyDPadButton *> temphash = getApplicableButtons();

#8
src/x11extras.cpp:559: error: Null Dereference
pointer `null_char` last assigned on line 556 could be null and is dereferenced at line 559, column 13.
557.         if (((reinterpret_cast<char *>(prop)) + nitems - 1) > null_char)
558.         {
559.             *(null_char) = ' ';
                 ^
560.         }
561. 

#9
src/inputdevice.cpp:606: error: Null Dereference
pointer `button` last assigned on line 595 could be null and is dereferenced at line 606, column 5.
604. 
605.     JoyButton::SetChangeCondition tempmode = static_cast<JoyButton::SetChangeCondition>(mode);
606.     button->setChangeSetSelection(originset);
         ^
607.     button->setChangeSetCondition(tempmode, true);
608. }

#10
src/x11extras.cpp:657: error: Dead Store
The value written to &feedbacks (type XFeedbackState*) is never used.
655. 
656.             XFree(feedbacks);
657.             feedbacks = temp = nullptr;
                 ^
658. 
659.             if (feedback_id <= -1)

#11
src/x11extras.cpp:753: error: Dead Store
The value written to &feedbacks (type XFeedbackState*) is never used.
751. 
752.             XFree(feedbacks);
753.             feedbacks = temp = nullptr;
                 ^
754.             XCloseDevice(display, device);
755.         }

#12
src/gui/axiseditdialog.cpp:722: error: Uninitialized Value
The value read from mode was never initialized.
720.         break;
721.     }
722.     m_axis->setHapticTriggerMode(mode);
         ^
723. }

#13
src/x11extras.cpp:773: error: Dead Store
The value written to &mouse_device (type XIDeviceInfo*) is never used.
771.         if ((current_devices->use == XISlavePointer) && (QString::fromUtf8(current_devices->name) == pointerName))
772.         {
773.             mouse_device = current_devices;
                 ^
774.         }
775.     }

#14
src/gui/advancebuttondialog.cpp:895: error: Dead Store
The value written to &chosen_set (type int) is never used.
893.     PadderCommon::inputDaemonMutex.lock();
894. 
895.     int chosen_set = -1;
         ^
896.     JoyButton::SetChangeCondition set_selection_condition = JoyButton::SetChangeDisabled;
897. 

#15
src/joybutton.cpp:1143: error: Dead Store
The value written to &elapsedDiff (type double) is never used.
1141.                             // Determine the multiplier to use for the current maximum mouse speed
1142.                             // based on how much time has passed.
1143.                             double elapsedDiff = 1.0;
                                  ^
1144.                             if ((easingDuration > 0.0) && ((easingElapsed * .001) < easingDuration))
1145.                             {

#16
src/joybutton.cpp:1294: error: Dead Store
The value written to &elapsedDiff (type double) is never used.
1292. 
1293.                         double tempAccel = currentAccelMultiTemp;
1294.                         double elapsedDiff = 1.0;
                              ^
1295. 
1296.                         if ((elapsedDuration > 0.0) && ((elapsedElapsed * 0.001) < elapsedDuration))

#17
src/joybutton.cpp:1308: error: Dead Store
The value written to &elapsedDiff (type double) is never used.
1306.                         } else
1307.                         {
1308.                             elapsedDiff = 1.0;
                                  ^
1309.                             currentAccelMulti = 0.0;
1310.                             updateOldAccelMulti = 0.0;

#18
src/joycontrolstick.cpp:1988: error: Dead Store
The value written to &initialCurve (type int) is never used.
1986.     bool result = true;
1987. 
1988.     JoyButton::JoyMouseCurve initialCurve = JoyButton::LinearCurve;
          ^
1989.     QHash<JoyStickDirections, JoyControlStickButton *> temphash = getApplicableButtons();
1990.     auto iter = temphash.cbegin();

#19
src/joybutton.cpp:3804: error: Dead Store
The value written to &tempx (type double) is never used.
3802.         for (int i = (springXSpeeds->length() - 1); (i >= 0) && !complete; i--)
3803.         {
3804.             double tempx = -2.0;
                  ^
3805.             double tempy = -2.0;
3806.             double tempSpringDeadX = 0.0;

#20
src/joybutton.cpp:3805: error: Dead Store
The value written to &tempy (type double) is never used.
3803.         {
3804.             double tempx = -2.0;
3805.             double tempy = -2.0;
                  ^
3806.             double tempSpringDeadX = 0.0;
3807.             double tempSpringDeadY = 0.0;

Found 21 issues
              Issue Type(ISSUED_TYPE_ID): #
                  Dead Store(DEAD_STORE): 18
      Null Dereference(NULL_DEREFERENCE): 2
Uninitialized Value(UNINITIALIZED_VALUE): 1

Most of them are very simple ones, mostly never used variables.

@pktiuk pktiuk added good first issue Good for newcomers refactor Issues connected with cleaning-up repository low-priotity labels Oct 10, 2022
@Stefan-TU
Copy link
Contributor

Hi, could I take this Issue?

@pktiuk
Copy link
Member Author

pktiuk commented Oct 10, 2022

Yes

Stefan-TU added a commit to Stefan-TU/antimicrox that referenced this issue Oct 10, 2022
Stefan-TU added a commit to Stefan-TU/antimicrox that referenced this issue Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers low-priotity refactor Issues connected with cleaning-up repository
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants