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
This commit is contained in:
Carlo Teubner 2019-11-24 14:40:16 +00:00 committed by Jonathan White
parent c663b5d5fc
commit f62e0534a2
6 changed files with 18 additions and 24 deletions

View File

@ -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;

View File

@ -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;

View File

@ -35,6 +35,7 @@
IconStruct::IconStruct()
: uuid(QUuid())
, number(0)
, applyTo(ApplyIconToOptions::THIS_ONLY)
{
}

View File

@ -483,9 +483,7 @@ MainWindow::MainWindow()
#endif
// clang-format off
connect(m_ui->tabWidget,
SIGNAL(messageGlobal(QString,MessageWidget::MessageType)),
this,
connect(m_ui->tabWidget, SIGNAL(messageGlobal(QString,MessageWidget::MessageType)),
SLOT(displayGlobalMessage(QString,MessageWidget::MessageType)));
// clang-format on
@ -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()) {

View File

@ -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));
}
}

View File

@ -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) {