From f62e0534a23c2030c9c22e6f3db25148fcb486fd Mon Sep 17 00:00:00 2001 From: Carlo Teubner Date: Sun, 24 Nov 2019 14:40:16 +0000 Subject: [PATCH] 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 --- src/autotype/xcb/AutoTypeXCB.cpp | 17 ++++++----------- src/core/ScreenLockListenerWin.h | 2 +- src/gui/EditWidgetIcons.cpp | 1 + src/gui/MainWindow.cpp | 14 ++++++-------- src/gui/MessageBox.cpp | 4 ++-- 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