From: Manuel Nickschas Date: Tue, 19 Dec 2017 21:37:45 +0000 (+0100) Subject: qa: Add [[fallthrough]] annotations where appropriate X-Git-Tag: travis-deploy-test~228 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=45affd4fa815bb21d0b2e46ac80114bb9174f801;ds=sidebyside qa: Add [[fallthrough]] annotations where appropriate Newer GCCs start to warn about this, so add attributes or rearrange code as appropriate. While the [[fallthrough]] attribute has only been standardized in C++17, it should simply be ignored by older compilers (and it does shut up GCC even when compiling with -std=c++11). --- diff --git a/src/common/ircchannel.cpp b/src/common/ircchannel.cpp index a5d5c822..c759e1dd 100644 --- a/src/common/ircchannel.cpp +++ b/src/common/ircchannel.cpp @@ -555,9 +555,8 @@ bool IrcChannel::hasMode(const QChar &mode) const return _C_channelModes.contains(mode); case Network::D_CHANMODE: return _D_channelModes.contains(mode); - default: - return false; } + return false; } @@ -590,9 +589,11 @@ QStringList IrcChannel::modeValueList(const QChar &mode) const case Network::A_CHANMODE: if (_A_channelModes.contains(mode)) return _A_channelModes[mode]; + break; default: - return QStringList(); + ; } + return {}; } diff --git a/src/core/coresessioneventprocessor.cpp b/src/core/coresessioneventprocessor.cpp index 7c414ba1..ff1d2415 100644 --- a/src/core/coresessioneventprocessor.cpp +++ b/src/core/coresessioneventprocessor.cpp @@ -985,10 +985,13 @@ void CoreSessionEventProcessor::processIrcEvent322(IrcEvent *e) switch (e->params().count()) { case 3: topic = e->params()[2]; + [[fallthrough]]; case 2: userCount = e->params()[1].toUInt(); + [[fallthrough]]; case 1: channelName = e->params()[0]; + [[fallthrough]]; default: break; } diff --git a/src/core/eventstringifier.cpp b/src/core/eventstringifier.cpp index 43d29d9a..b0f9d307 100644 --- a/src/core/eventstringifier.cpp +++ b/src/core/eventstringifier.cpp @@ -598,10 +598,13 @@ void EventStringifier::processIrcEvent322(IrcEvent *e) switch (e->params().count()) { case 3: topic = e->params()[2]; + [[fallthrough]]; case 2: userCount = e->params()[1].toUInt(); + [[fallthrough]]; case 1: channelName = e->params()[0]; + [[fallthrough]]; default: break; } diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index 3044fcc8..473f66e5 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -1836,12 +1836,15 @@ bool SqliteStorage::safeExec(QSqlQuery &query, int retryCount) switch (query.lastError().number()) { case 5: // SQLITE_BUSY 5 /* The database file is locked */ + [[fallthrough]]; case 6: // SQLITE_LOCKED 6 /* A table in the database is locked */ if (retryCount < _maxRetryCount) return safeExec(query, retryCount + 1); + break; default: - return false; + ; } + return false; } diff --git a/src/qtui/bufferwidget.cpp b/src/qtui/bufferwidget.cpp index 52a275b3..f11094ba 100644 --- a/src/qtui/bufferwidget.cpp +++ b/src/qtui/bufferwidget.cpp @@ -232,6 +232,7 @@ bool BufferWidget::eventFilter(QObject *watched, QEvent *event) case Qt::Key_Down: if (!(keyEvent->modifiers() & Qt::ShiftModifier)) return false; + [[fallthrough]]; case Qt::Key_PageUp: case Qt::Key_PageDown: // static cast to access public qobject::event diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index dbe4220e..d609f0a8 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -1290,6 +1290,7 @@ void ChatScene::webPreviewNextStep() if (webPreview.previewItem && webPreview.previewItem->scene()) removeItem(webPreview.previewItem); // Fall through to deletion! + [[fallthrough]]; case WebPreview::HidePreview: if (webPreview.previewItem) { delete webPreview.previewItem; @@ -1317,6 +1318,7 @@ void ChatScene::clearWebPreview(ChatItem *parentItem) removeItem(webPreview.previewItem); } // fall through into to set hidden state + [[fallthrough]]; case WebPreview::DelayPreview: // we're just loading, so haven't shown the preview yet. webPreview.previewState = WebPreview::HidePreview; diff --git a/src/uisupport/networkmodelcontroller.cpp b/src/uisupport/networkmodelcontroller.cpp index aaccc05f..88e48e31 100644 --- a/src/uisupport/networkmodelcontroller.cpp +++ b/src/uisupport/networkmodelcontroller.cpp @@ -362,6 +362,7 @@ void NetworkModelController::handleHideAction(ActionType type, QAction *action) return; case HideApplyToAll: BufferSettings().setMessageFilter(filter); + [[fallthrough]]; case HideUseDefaults: if (_messageFilter) BufferSettings(_messageFilter->idString()).removeFilter(); diff --git a/src/uisupport/tabcompleter.cpp b/src/uisupport/tabcompleter.cpp index df5e1438..46d8a8df 100644 --- a/src/uisupport/tabcompleter.cpp +++ b/src/uisupport/tabcompleter.cpp @@ -109,6 +109,7 @@ void TabCompleter::buildCompletionList() case BufferInfo::QueryBuffer: if (regex.indexIn(_currentBufferName) > -1) _completionMap[_currentBufferName.toLower()] = _currentBufferName; + [[fallthrough]]; case BufferInfo::StatusBuffer: if (!_currentNetwork->myNick().isEmpty() && regex.indexIn(_currentNetwork->myNick()) > -1) _completionMap[_currentNetwork->myNick().toLower()] = _currentNetwork->myNick();