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>
Tue, 19 Dec 2017 22:25:23 +0000 (23:25 +0100)
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).

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 a5d5c82..c759e1d 100644 (file)
@@ -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 {};
 }
 
 
index 7c414ba..ff1d241 100644 (file)
@@ -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;
     }
index 43d29d9..b0f9d30 100644 (file)
@@ -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;
     }
index 3044fcc..473f66e 100644 (file)
@@ -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;
 }
 
 
index 52a275b..f11094b 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 dbe4220..d609f0a 100644 (file)
@@ -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;
index aaccc05..88e48e3 100644 (file)
@@ -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();
index df5e143..46d8a8d 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();