Remove the use of goto from src/csync/csync_exclude.cpp
authorHannah von Reth <hannah.vonreth@owncloud.com>
Mon, 10 Aug 2020 14:22:38 +0000 (16:22 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:59:19 +0000 (10:59 +0100)
src/csync/csync_exclude.cpp

index 390095f7690a2c8ddcf0a27c1820325cd165b92b..8d342b45d8c840fd9da172c99ed921e3c1cab79c 100644 (file)
@@ -132,9 +132,6 @@ OCSYNC_EXPORT bool csync_is_windows_reserved_word(const QStringRef &filename)
 
 static CSYNC_EXCLUDE_TYPE _csync_excluded_common(const QString &path, bool excludeConflictFiles)
 {
-    int rc = -1;
-    CSYNC_EXCLUDE_TYPE match = CSYNC_NOT_EXCLUDED;
-
     /* split up the path */
     QStringRef bname(&path);
     int lastSlash = path.lastIndexOf(QLatin1Char('/'));
@@ -160,8 +157,7 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(const QString &path, bool exclu
     // check the strlen and ignore the file if its name is longer than 254 chars.
     // whenever changing this also check createDownloadTmpFileName
     if (blen > 254) {
-        match = CSYNC_FILE_EXCLUDE_LONG_FILENAME;
-        goto out;
+        return CSYNC_FILE_EXCLUDE_LONG_FILENAME;
     }
 
 #ifdef _WIN32
@@ -171,17 +167,14 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(const QString &path, bool exclu
     // not allow to sync those to avoid file loss/ambiguities (#416)
     if (blen > 1) {
         if (bname.at(blen - 1) == QLatin1Char(' ')) {
-            match = CSYNC_FILE_EXCLUDE_TRAILING_SPACE;
-            goto out;
+            return CSYNC_FILE_EXCLUDE_TRAILING_SPACE;
         } else if (bname.at(blen - 1) == QLatin1Char('.')) {
-            match = CSYNC_FILE_EXCLUDE_INVALID_CHAR;
-            goto out;
+            return CSYNC_FILE_EXCLUDE_INVALID_CHAR;
         }
     }
 
     if (csync_is_windows_reserved_word(bname)) {
-      match = CSYNC_FILE_EXCLUDE_INVALID_CHAR;
-      goto out;
+        return CSYNC_FILE_EXCLUDE_INVALID_CHAR;
     }
 
     // Filter out characters not allowed in a filename on windows
@@ -199,8 +192,7 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(const QString &path, bool exclu
         case '>':
         case '<':
         case '|':
-            match = CSYNC_FILE_EXCLUDE_INVALID_CHAR;
-            goto out;
+            return CSYNC_FILE_EXCLUDE_INVALID_CHAR;
         default:
             break;
         }
@@ -209,21 +201,15 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(const QString &path, bool exclu
 
     /* We create a Desktop.ini on Windows for the sidebar icon, make sure we don't sync it. */
     if (blen == 11 && path == bname) {
-        rc = bname.compare(QLatin1String("Desktop.ini"), Qt::CaseInsensitive);
-        if (rc == 0) {
-            match = CSYNC_FILE_SILENTLY_EXCLUDED;
-            goto out;
+        if (bname.compare(QLatin1String("Desktop.ini"), Qt::CaseInsensitive) == 0) {
+            return CSYNC_FILE_SILENTLY_EXCLUDED;
         }
     }
 
     if (excludeConflictFiles && OCC::Utility::isConflictFile(path)) {
-        match = CSYNC_FILE_EXCLUDE_CONFLICT;
-        goto out;
+        return CSYNC_FILE_EXCLUDE_CONFLICT;
     }
-
-  out:
-
-    return match;
+    return CSYNC_NOT_EXCLUDED;
 }
 
 static QString leftIncludeLast(const QString &arr, const QChar &c)