qa: Add [[fallthrough]] annotations where appropriate
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 19 Dec 2017 21:37:45 +0000 (22:37 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 4 Apr 2018 21:14:04 +0000 (23:14 +0200)
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).

(cherry picked from commit 45affd4fa815bb21d0b2e46ac80114bb9174f801)

src/common/ircchannel.cpp
src/core/coresessioneventprocessor.cpp
src/core/eventstringifier.cpp
src/core/sqlitestorage.cpp
src/qtui/bufferwidget.cpp
src/qtui/chatscene.cpp
src/uisupport/networkmodelcontroller.cpp
src/uisupport/tabcompleter.cpp

index c111b9f..b40cbd6 100644 (file)
@@ -547,9 +547,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;
 }
 
 
@@ -582,9 +581,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 {};
 }
 
 
index ed2904c..b97b532 100644 (file)
@@ -718,10 +718,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;
     }
index 66f0e27..ae1b2b0 100644 (file)
@@ -531,10 +531,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;
     }
index 2590655..a07c2fa 100644 (file)
@@ -1720,12 +1720,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;
 }
 
 
index 6b01050..86d3e2e 100644 (file)
@@ -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
index c9816d5..00a6bb0 100644 (file)
@@ -1258,6 +1258,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;
@@ -1285,6 +1286,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;
index a8946ed..c9a1594 100644 (file)
@@ -358,6 +358,7 @@ void NetworkModelController::handleHideAction(ActionType type, QAction *action)
         return;
     case HideApplyToAll:
         BufferSettings().setMessageFilter(filter);
+        [[fallthrough]];
     case HideUseDefaults:
         if (_messageFilter)
             BufferSettings(_messageFilter->idString()).removeFilter();
index b0e61fd..5d6e889 100644 (file)
@@ -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();