diff options
author | Carlo Teubner <carlo@cteubner.net> | 2019-11-24 17:40:16 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2020-02-02 16:46:58 +0300 |
commit | f62e0534a23c2030c9c22e6f3db25148fcb486fd (patch) | |
tree | 80ecd223b335e999bbb6a7d903fe399000ecde95 | |
parent | c663b5d5fcc3ed9f5af8d6e5e7fdf1e99f4a2c58 (diff) |
Fixes for minor issues found by static analysis
Mostly style issues.
I used the following tools to find most of these:
- lgtm.com
- clang-tidy
- cpplint
- cppcheck
-rw-r--r-- | src/autotype/xcb/AutoTypeXCB.cpp | 17 | ||||
-rw-r--r-- | src/core/ScreenLockListenerWin.h | 2 | ||||
-rw-r--r-- | src/gui/EditWidgetIcons.cpp | 1 | ||||
-rw-r--r-- | src/gui/MainWindow.cpp | 14 | ||||
-rw-r--r-- | src/gui/MessageBox.cpp | 4 | ||||
-rw-r--r-- | tests/TestSymmetricCipher.cpp | 4 |
6 files changed, 18 insertions, 24 deletions
diff --git a/src/autotype/xcb/AutoTypeXCB.cpp b/src/autotype/xcb/AutoTypeXCB.cpp index 94a132d40..d2d757b4e 100644 --- a/src/autotype/xcb/AutoTypeXCB.cpp +++ b/src/autotype/xcb/AutoTypeXCB.cpp @@ -485,10 +485,6 @@ KeySym AutoTypePlatformX11::keyToKeySym(Qt::Key key) */ void AutoTypePlatformX11::updateKeymap() { - int keycode, inx; - int mod_index, mod_key; - XModifierKeymap* modifiers; - if (m_xkb) { XkbFreeKeyboard(m_xkb, XkbAllComponentsMask, True); } @@ -500,10 +496,9 @@ void AutoTypePlatformX11::updateKeymap() m_keysymTable = XGetKeyboardMapping(m_dpy, m_minKeycode, m_maxKeycode - m_minKeycode + 1, &m_keysymPerKeycode); /* determine the keycode to use for remapped keys */ - inx = (m_remapKeycode - m_minKeycode) * m_keysymPerKeycode; if (m_remapKeycode == 0 || !isRemapKeycodeValid()) { - for (keycode = m_minKeycode; keycode <= m_maxKeycode; keycode++) { - inx = (keycode - m_minKeycode) * m_keysymPerKeycode; + for (int keycode = m_minKeycode; keycode <= m_maxKeycode; keycode++) { + int inx = (keycode - m_minKeycode) * m_keysymPerKeycode; if (m_keysymTable[inx] == NoSymbol) { m_remapKeycode = keycode; m_currentRemapKeysym = NoSymbol; @@ -513,11 +508,11 @@ void AutoTypePlatformX11::updateKeymap() } /* determine the keycode to use for modifiers */ - modifiers = XGetModifierMapping(m_dpy); - for (mod_index = ShiftMapIndex; mod_index <= Mod5MapIndex; mod_index++) { + XModifierKeymap* modifiers = XGetModifierMapping(m_dpy); + for (int mod_index = ShiftMapIndex; mod_index <= Mod5MapIndex; mod_index++) { m_modifier_keycode[mod_index] = 0; - for (mod_key = 0; mod_key < modifiers->max_keypermod; mod_key++) { - keycode = modifiers->modifiermap[mod_index * modifiers->max_keypermod + mod_key]; + for (int mod_key = 0; mod_key < modifiers->max_keypermod; mod_key++) { + int keycode = modifiers->modifiermap[mod_index * modifiers->max_keypermod + mod_key]; if (keycode) { m_modifier_keycode[mod_index] = keycode; break; diff --git a/src/core/ScreenLockListenerWin.h b/src/core/ScreenLockListenerWin.h index 523ae5d0b..ba7c98cd3 100644 --- a/src/core/ScreenLockListenerWin.h +++ b/src/core/ScreenLockListenerWin.h @@ -29,7 +29,7 @@ class ScreenLockListenerWin : public ScreenLockListenerPrivate, public QAbstract public: explicit ScreenLockListenerWin(QWidget* parent = nullptr); ~ScreenLockListenerWin(); - virtual bool nativeEventFilter(const QByteArray& eventType, void* message, long*) override; + bool nativeEventFilter(const QByteArray& eventType, void* message, long*) override; private: void* m_powerNotificationHandle; diff --git a/src/gui/EditWidgetIcons.cpp b/src/gui/EditWidgetIcons.cpp index 83bc0fc35..054156066 100644 --- a/src/gui/EditWidgetIcons.cpp +++ b/src/gui/EditWidgetIcons.cpp @@ -35,6 +35,7 @@ IconStruct::IconStruct() : uuid(QUuid()) , number(0) + , applyTo(ApplyIconToOptions::THIS_ONLY) { } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 2d52331ff..2f5472363 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -214,9 +214,9 @@ MainWindow::MainWindow() setWindowIcon(filePath()->applicationIcon()); m_ui->globalMessageWidget->setHidden(true); // clang-format off - connect(m_ui->globalMessageWidget, &MessageWidget::linkActivated, &MessageWidget::openHttpUrl); - connect(m_ui->globalMessageWidget, SIGNAL(showAnimationStarted()), m_ui->globalMessageWidgetContainer, SLOT(show())); - connect(m_ui->globalMessageWidget, SIGNAL(hideAnimationFinished()), m_ui->globalMessageWidgetContainer, SLOT(hide())); + connect(m_ui->globalMessageWidget, &MessageWidget::linkActivated, &MessageWidget::openHttpUrl); + connect(m_ui->globalMessageWidget, SIGNAL(showAnimationStarted()), m_ui->globalMessageWidgetContainer, SLOT(show())); + connect(m_ui->globalMessageWidget, SIGNAL(hideAnimationFinished()), m_ui->globalMessageWidgetContainer, SLOT(hide())); // clang-format on m_clearHistoryAction = new QAction(tr("Clear history"), m_ui->menuFile); @@ -483,10 +483,8 @@ MainWindow::MainWindow() #endif // clang-format off - connect(m_ui->tabWidget, - SIGNAL(messageGlobal(QString,MessageWidget::MessageType)), - this, - SLOT(displayGlobalMessage(QString,MessageWidget::MessageType))); + connect(m_ui->tabWidget, SIGNAL(messageGlobal(QString,MessageWidget::MessageType)), + SLOT(displayGlobalMessage(QString,MessageWidget::MessageType))); // clang-format on connect(m_ui->tabWidget, SIGNAL(messageDismissGlobal()), this, SLOT(hideGlobalMessage())); @@ -1322,7 +1320,7 @@ void MainWindow::toggleWindow() // see https://github.com/keepassxreboot/keepassxc/issues/271 // and https://bugreports.qt.io/browse/QTBUG-58723 // check for !isVisible(), because isNativeMenuBar() does not work with appmenu-qt5 - const static auto isDesktopSessionUnity = qgetenv("XDG_CURRENT_DESKTOP") == "Unity"; + static const auto isDesktopSessionUnity = qgetenv("XDG_CURRENT_DESKTOP") == "Unity"; if (isDesktopSessionUnity && Tools::qtRuntimeVersion() < QT_VERSION_CHECK(5, 9, 0) && !m_ui->menubar->isVisible()) { diff --git a/src/gui/MessageBox.cpp b/src/gui/MessageBox.cpp index 7d2b2a516..317754a62 100644 --- a/src/gui/MessageBox.cpp +++ b/src/gui/MessageBox.cpp @@ -98,10 +98,10 @@ MessageBox::Button MessageBox::messageBox(QWidget* parent, for (uint64_t b = First; b <= Last; b <<= 1) { if (b & buttons) { - QString text = m_buttonDefs[static_cast<Button>(b)].first; + QString buttonText = m_buttonDefs[static_cast<Button>(b)].first; QMessageBox::ButtonRole role = m_buttonDefs[static_cast<Button>(b)].second; - auto buttonPtr = msgBox.addButton(text, role); + auto buttonPtr = msgBox.addButton(buttonText, role); m_addedButtonLookup.insert(buttonPtr, static_cast<Button>(b)); } } diff --git a/tests/TestSymmetricCipher.cpp b/tests/TestSymmetricCipher.cpp index 173f328ee..bc872a510 100644 --- a/tests/TestSymmetricCipher.cpp +++ b/tests/TestSymmetricCipher.cpp @@ -279,7 +279,6 @@ void TestSymmetricCipher::testTwofish256CbcEncryption() QByteArray::fromHex("6F725C5950133F82EF021A94CADC8508")}; SymmetricCipher cipher(SymmetricCipher::Twofish, SymmetricCipher::Cbc, SymmetricCipher::Encrypt); - bool ok; for (int i = 0; i < keys.size(); ++i) { QVERIFY(cipher.init(keys[i], ivs[i])); @@ -287,6 +286,7 @@ void TestSymmetricCipher::testTwofish256CbcEncryption() QByteArray ctPrev = ivs[i]; QByteArray ctCur; QCOMPARE(cipher.blockSize(), 16); + bool ok = false; for (int j = 0; j < 5000; ++j) { ctCur = cipher.process(ptNext, &ok); if (!ok) { @@ -335,13 +335,13 @@ void TestSymmetricCipher::testTwofish256CbcDecryption() QByteArray::fromHex("4C81F5BDC1081170FF96F50B1F76A566")}; SymmetricCipher cipher(SymmetricCipher::Twofish, SymmetricCipher::Cbc, SymmetricCipher::Decrypt); - bool ok; for (int i = 0; i < keys.size(); ++i) { cipher.init(keys[i], ivs[i]); QByteArray ctNext = cipherTexts[i]; QByteArray ptCur; QCOMPARE(cipher.blockSize(), 16); + bool ok = false; for (int j = 0; j < 5000; ++j) { ptCur = cipher.process(ctNext, &ok); if (!ok) { |