OSDN Git Service

Fix various "C26819: Unannotated fallthrough between switch labels" warnings
authorGreyMerlin <greymerlin7@gmail.com>
Mon, 4 Jan 2021 16:50:43 +0000 (08:50 -0800)
committerGreyMerlin <greymerlin7@gmail.com>
Mon, 4 Jan 2021 16:54:50 +0000 (08:54 -0800)
Externals/poco/XML/src/siphash.h
Externals/poco/XML/src/xmlparse.cpp
Src/Common/LanguageSelect.cpp
Src/DirView.cpp
Src/OpenView.cpp
Src/markdown.cpp

index bfee65a..01dc664 100644 (file)
@@ -240,25 +240,25 @@ sip24_final(struct siphash *H) {
   switch (left) {
   case 7:
     b |= (uint64_t)H->buf[6] << 48;
-    /* fall through */
+    [[fallthrough]];
   case 6:
     b |= (uint64_t)H->buf[5] << 40;
-    /* fall through */
+    [[fallthrough]];
   case 5:
     b |= (uint64_t)H->buf[4] << 32;
-    /* fall through */
+    [[fallthrough]];
   case 4:
     b |= (uint64_t)H->buf[3] << 24;
-    /* fall through */
+    [[fallthrough]];
   case 3:
     b |= (uint64_t)H->buf[2] << 16;
-    /* fall through */
+    [[fallthrough]];
   case 2:
     b |= (uint64_t)H->buf[1] << 8;
-    /* fall through */
+    [[fallthrough]];
   case 1:
     b |= (uint64_t)H->buf[0] << 0;
-    /* fall through */
+    [[fallthrough]];
   case 0:
     break;
   }
index d0be272..ace8ede 100644 (file)
@@ -1738,7 +1738,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) {
       parser->m_errorCode = XML_ERROR_NO_MEMORY;
       return XML_STATUS_ERROR;
     }
-    /* fall through */
+    [[fallthrough]];
   default:
     parser->m_parsingStatus.parsing = XML_PARSING;
   }
@@ -1781,7 +1781,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) {
       case XML_INITIALIZED:
       case XML_PARSING:
         parser->m_parsingStatus.parsing = XML_FINISHED;
-        /* fall through */
+        [[fallthrough]];
       default:
         return XML_STATUS_OK;
       }
@@ -1824,7 +1824,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) {
           parser->m_parsingStatus.parsing = XML_FINISHED;
           return XML_STATUS_OK;
         }
-      /* fall through */
+      [[fallthrough]];
       default:
         result = XML_STATUS_OK;
       }
@@ -1892,7 +1892,7 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal) {
       parser->m_errorCode = XML_ERROR_NO_MEMORY;
       return XML_STATUS_ERROR;
     }
-    /* fall through */
+    [[fallthrough]];
   default:
     parser->m_parsingStatus.parsing = XML_PARSING;
   }
@@ -1922,7 +1922,9 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal) {
         parser->m_parsingStatus.parsing = XML_FINISHED;
         return result;
       }
-    default:; /* should not happen */
+      [[fallthrough]];
+    default: /* should not happen */
+        break;
     }
   }
 
@@ -1947,7 +1949,8 @@ XML_GetBuffer(XML_Parser parser, int len) {
   case XML_FINISHED:
     parser->m_errorCode = XML_ERROR_FINISHED;
     return NULL;
-  default:;
+  default:
+    break;
   }
 
   if (len > EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferEnd)) {
@@ -2110,7 +2113,9 @@ XML_ResumeParser(XML_Parser parser) {
         parser->m_parsingStatus.parsing = XML_FINISHED;
         return result;
       }
-    default:;
+         [[fallthrough]];
+    default:
+      break;
     }
   }
 
@@ -2706,7 +2711,6 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
       break;
     }
     case XML_TOK_START_TAG_NO_ATTS:
-      /* fall through */
     case XML_TOK_START_TAG_WITH_ATTS: {
       TAG *tag;
       enum XML_Error result;
@@ -2774,7 +2778,6 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
       break;
     }
     case XML_TOK_EMPTY_ELEMENT_NO_ATTS:
-      /* fall through */
     case XML_TOK_EMPTY_ELEMENT_WITH_ATTS: {
       const char *rawName = s + enc->minBytesPerChar;
       enum XML_Error result;
@@ -3010,7 +3013,8 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
       return XML_ERROR_NONE;
     case XML_FINISHED:
       return XML_ERROR_ABORTED;
-    default:;
+    default:
+      break;
     }
   }
   /* not reached */
@@ -3587,7 +3591,7 @@ doCdataSection(XML_Parser parser, const ENCODING *enc, const char **startPtr,
   *startPtr = NULL;
 
   for (;;) {
-    const char *next;
+    const char *next = nullptr;
     int tok = XmlCdataSectionTok(enc, s, end, &next);
     *eventEndPP = next;
     switch (tok) {
@@ -3673,7 +3677,8 @@ doCdataSection(XML_Parser parser, const ENCODING *enc, const char **startPtr,
       return XML_ERROR_NONE;
     case XML_FINISHED:
       return XML_ERROR_ABORTED;
-    default:;
+    default:
+      break;
     }
   }
   /* not reached */
@@ -3705,7 +3710,7 @@ ignoreSectionProcessor(XML_Parser parser, const char *start, const char *end,
 static enum XML_Error
 doIgnoreSection(XML_Parser parser, const ENCODING *enc, const char **startPtr,
                 const char *end, const char **nextPtr, XML_Bool haveMore) {
-  const char *next;
+  const char *next = nullptr;
   int tok;
   const char *s = *startPtr;
   const char **eventPP;
@@ -4266,7 +4271,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
         handleDefault = XML_FALSE;
         goto alreadyChecked;
       }
-      /* fall through */
+      [[fallthrough]];
     case XML_ROLE_ENTITY_PUBLIC_ID:
       if (! XmlIsPublicId(enc, s, next, eventPP))
         return XML_ERROR_PUBLICID;
@@ -4569,8 +4574,8 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
           return XML_ERROR_NO_MEMORY;
         parser->m_declEntity->publicId = NULL;
       }
+      [[fallthrough]];
 #endif /* XML_DTD */
-      /* fall through */
     case XML_ROLE_ENTITY_SYSTEM_ID:
       if (dtd->keepProcessing && parser->m_declEntity) {
         parser->m_declEntity->systemId
@@ -5156,7 +5161,8 @@ epilogProcessor(XML_Parser parser, const char *s, const char *end,
       return XML_ERROR_NONE;
     case XML_FINISHED:
       return XML_ERROR_ABORTED;
-    default:;
+    default:
+      break;
     }
   }
 }
@@ -5306,7 +5312,7 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
                      const char *ptr, const char *end, STRING_POOL *pool) {
   DTD *const dtd = parser->m_dtd; /* save one level of indirection */
   for (;;) {
-    const char *next;
+    const char *next = nullptr;
     int tok = XmlAttributeValueTok(enc, ptr, end, &next);
     switch (tok) {
     case XML_TOK_NONE:
@@ -5352,7 +5358,7 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
       break;
     case XML_TOK_TRAILING_CR:
       next = ptr + enc->minBytesPerChar;
-      /* fall through */
+      [[fallthrough]];
     case XML_TOK_ATTRIBUTE_VALUE_S:
     case XML_TOK_DATA_NEWLINE:
       if (! isCdata && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20))
@@ -5493,7 +5499,7 @@ storeEntityValue(XML_Parser parser, const ENCODING *enc,
   }
 
   for (;;) {
-    const char *next;
+    const char *next = nullptr;
     int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next);
     switch (tok) {
     case XML_TOK_PARAM_ENTITY_REF:
@@ -5571,7 +5577,7 @@ storeEntityValue(XML_Parser parser, const ENCODING *enc,
       break;
     case XML_TOK_TRAILING_CR:
       next = entityTextPtr + enc->minBytesPerChar;
-      /* fall through */
+      [[fallthrough]];
     case XML_TOK_DATA_NEWLINE:
       if (pool->end == pool->ptr && ! poolGrow(pool)) {
         result = XML_ERROR_NO_MEMORY;
index 52f641f..681e836 100644 (file)
@@ -551,7 +551,7 @@ static void unslash(std::wstring &s)
                        }
                        if (q >= r)
                                break;
-                       // fall through
+                       [[fallthrough]];
                default:
                        *p = c;
                        q = r;
index 5846757..e3c2983 100644 (file)
@@ -1246,13 +1246,11 @@ void CDirView::OpenParentDirectory()
                pDoc->m_pTempPathContext = pDoc->m_pTempPathContext->DeleteHead();
                [[fallthrough]];
        case AllowUpwardDirectory::ParentIsRegularPath: 
-       {
                DWORD dwFlags[3];
                for (int nIndex = 0; nIndex < pathsParent.GetSize(); ++nIndex)
                        dwFlags[nIndex] = FFILEOPEN_NOMRU | (pDoc->GetReadOnly(nIndex) ? FFILEOPEN_READONLY : 0);
                GetMainFrame()->DoFileOpen(&pathsParent, dwFlags, nullptr, _T(""), GetDiffContext().m_bRecursive, (GetAsyncKeyState(VK_CONTROL) & 0x8000) ? nullptr : pDoc);
                [[fallthrough]];
-       }
        case AllowUpwardDirectory::No:
                break;
        default:
@@ -2808,7 +2806,7 @@ int CDirView::AddSpecialItems()
        default:
                AddParentFolderItem(bEnable);
                retVal = 1;
-               // fall through
+               [[fallthrough]];
        case AllowUpwardDirectory::Never:
                break;
        }
index 4efe399..a6eb444 100644 (file)
@@ -389,7 +389,7 @@ void COpenView::OnMouseMove(UINT nFlags, CPoint point)
                                        SetCursor(m_hIconRotate);
                                        break;
                                }
-                               // fall through
+                               [[fallthrough]];
                        default:
                                SetCursor(m_hCursorNo);
                                break;
index 2ec2a5c..608d02f 100644 (file)
@@ -637,7 +637,7 @@ int CMarkdown::Token::IsSpecial(const char *p, const char *ahead)
                                        ++p;
                                } while (p < ahead && *p != c);
                        }
-                       // fall through
+                       [[fallthrough]];
                case '/':
                case '=':
                case '<':
@@ -802,6 +802,7 @@ CMarkdown::FileImage::FileImage(const TCHAR *path, size_t trunc, unsigned flags)
                        pImage = pCopy;
                        if (pImage != nullptr)
                        {
+                               [[fallthrough]];
                        case 2 + 0:
                        case 2 + 0 + 8:
                                // little endian
@@ -843,6 +844,7 @@ CMarkdown::FileImage::FileImage(const TCHAR *path, size_t trunc, unsigned flags)
                        pImage = pCopy;
                        if (pImage != nullptr)
                        {
+                               [[fallthrough]];
                        case 4 + 0:
                        case 4 + 0 + 8:
                        case 4 + 3: