From: Hannah von Reth Date: Mon, 10 Aug 2020 14:22:38 +0000 (+0200) Subject: Remove the use of goto from src/csync/csync_exclude.cpp X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~60 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f220151527539599eddadf291401d1c09741a226;p=nextcloud-desktop.git Remove the use of goto from src/csync/csync_exclude.cpp --- diff --git a/src/csync/csync_exclude.cpp b/src/csync/csync_exclude.cpp index 390095f76..8d342b45d 100644 --- a/src/csync/csync_exclude.cpp +++ b/src/csync/csync_exclude.cpp @@ -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)