Skip to content

Commit

Permalink
Resolve compiler warnings for unused return values
Browse files Browse the repository at this point in the history
* Fixes keepassxreboot#1932 - See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425#c29

Adding a negation before the function call allows the (void) syntax to work properly.
  • Loading branch information
droidmonkey committed Jun 12, 2021
1 parent a0912b0 commit 6a8b070
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/gui/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void Application::handleUnixSignal(int sig)
case SIGINT:
case SIGTERM: {
char buf = 0;
Q_UNUSED(::write(unixSignalSocket[0], &buf, sizeof(buf)));
Q_UNUSED(!::write(unixSignalSocket[0], &buf, sizeof(buf)));
return;
}
case SIGHUP:
Expand All @@ -268,7 +268,7 @@ void Application::quitBySignal()
{
m_unixSignalNotifier->setEnabled(false);
char buf;
Q_UNUSED(::read(unixSignalSocket[1], &buf, sizeof(buf)));
Q_UNUSED(!::read(unixSignalSocket[1], &buf, sizeof(buf)));
emit quitSignalReceived();
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/TestKeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void TestKeys::benchmarkTransformKey()

QBENCHMARK
{
Q_UNUSED(compositeKey->transform(kdf, result));
Q_UNUSED(!compositeKey->transform(kdf, result));
};
}

Expand Down
13 changes: 3 additions & 10 deletions tests/gui/TestGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ void TestGui::testTotp()
void TestGui::testSearch()
{
// Add canned entries for consistent testing
Q_UNUSED(addCannedEntries());
addCannedEntries();

auto* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");

Expand Down Expand Up @@ -1005,7 +1005,7 @@ void TestGui::testSearch()
void TestGui::testDeleteEntry()
{
// Add canned entries for consistent testing
Q_UNUSED(addCannedEntries());
addCannedEntries();

auto* groupView = m_dbWidget->findChild<GroupView*>("groupView");
auto* entryView = m_dbWidget->findChild<EntryView*>("entryView");
Expand Down Expand Up @@ -1685,10 +1685,8 @@ void TestGui::testAutoType()
entryView->selectionModel()->clearSelection();
}

int TestGui::addCannedEntries()
void TestGui::addCannedEntries()
{
int entries_added = 0;

// Find buttons
auto* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar");
QWidget* entryNewWidget = toolBar->widgetForAction(m_mainWindow->findChild<QAction*>("actionEntryNew"));
Expand All @@ -1701,22 +1699,17 @@ int TestGui::addCannedEntries()
QTest::keyClicks(titleEdit, "test");
auto* editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
++entries_added;

// Add entry "something 2"
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
QTest::keyClicks(titleEdit, "something 2");
QTest::keyClicks(passwordEdit, "something 2");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
++entries_added;

// Add entry "something 3"
QTest::mouseClick(entryNewWidget, Qt::LeftButton);
QTest::keyClicks(titleEdit, "something 3");
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
++entries_added;

return entries_added;
}

void TestGui::checkDatabase(QString dbFileName)
Expand Down
2 changes: 1 addition & 1 deletion tests/gui/TestGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private slots:
void testTrayRestoreHide();

private:
int addCannedEntries();
void addCannedEntries();
void checkDatabase(QString dbFileName = "");
void triggerAction(const QString& name);
void dragAndDropGroup(const QModelIndex& sourceIndex,
Expand Down

0 comments on commit 6a8b070

Please sign in to comment.