diff --git a/src/common/checksums.cpp b/src/common/checksums.cpp index f75e84f28..c604842a3 100644 --- a/src/common/checksums.cpp +++ b/src/common/checksums.cpp @@ -121,7 +121,7 @@ QByteArray calcAdler32(QIODevice *device) QByteArray buf(BUFSIZE, Qt::Uninitialized); unsigned int adler = adler32(0L, Z_NULL, 0); - qint64 size; + qint64 size = 0; while (!device->atEnd()) { size = device->read(buf.data(), BUFSIZE); if (size > 0) @@ -204,9 +204,7 @@ ComputeChecksum::ComputeChecksum(QObject *parent) { } -ComputeChecksum::~ComputeChecksum() -{ -} +ComputeChecksum::~ComputeChecksum() = default; void ComputeChecksum::setChecksumType(const QByteArray &type) { diff --git a/src/common/filesystembase.cpp b/src/common/filesystembase.cpp index f41b3a617..6b2271777 100644 --- a/src/common/filesystembase.cpp +++ b/src/common/filesystembase.cpp @@ -518,9 +518,9 @@ QString FileSystem::pathtoUNC(const QString &str) /* replace all occurences of / with the windows native \ */ - for (auto it = longStr.begin(); it != longStr.end(); ++it) { - if (*it == QLatin1Char('/')) { - *it = QLatin1Char('\\'); + for (auto &c : longStr) { + if (c == QLatin1Char('/')) { + c = QLatin1Char('\\'); } } return longStr; diff --git a/src/common/remotepermissions.cpp b/src/common/remotepermissions.cpp index f714277ed..00827f8f1 100644 --- a/src/common/remotepermissions.cpp +++ b/src/common/remotepermissions.cpp @@ -62,7 +62,7 @@ QString RemotePermissions::toString() const RemotePermissions RemotePermissions::fromDbValue(const QByteArray &value) { if (value.isEmpty()) - return RemotePermissions(); + return {}; RemotePermissions perm; perm.fromArray(value.constData()); return perm; diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp index 79fb9c561..8e2a6d81a 100644 --- a/src/common/syncjournaldb.cpp +++ b/src/common/syncjournaldb.cpp @@ -706,7 +706,7 @@ bool SyncJournalDb::updateMetadataTableStructure() commitInternal(QStringLiteral("update database structure: add path index")); } - if (1) { + if (true) { SqlQuery query(_db); query.prepare("CREATE INDEX IF NOT EXISTS metadata_parent ON metadata(parent_hash(path));"); if (!query.exec()) { diff --git a/src/common/vfs.h b/src/common/vfs.h index 66fae7e4b..f4ea3d8fa 100644 --- a/src/common/vfs.h +++ b/src/common/vfs.h @@ -25,12 +25,12 @@ #include "syncfilestatus.h" #include "pinstate.h" -typedef struct csync_file_stat_s csync_file_stat_t; +using csync_file_stat_t = struct csync_file_stat_s; namespace OCC { class Account; -typedef QSharedPointer AccountPtr; +using AccountPtr = QSharedPointer; class SyncJournalDb; class VfsPrivate; class SyncFileItem; @@ -329,7 +329,7 @@ OCSYNC_EXPORT std::unique_ptr createVfsFromPlugin(Vfs::Mode mode); namespace { \ void initPlugin() \ { \ - OCC::Vfs::registerPlugin(QStringLiteral(name), []() -> OCC::Vfs * { return new Type; }); \ + OCC::Vfs::registerPlugin(QStringLiteral(name), []() -> OCC::Vfs * { return new (Type); }); \ } \ Q_COREAPP_STARTUP_FUNCTION(initPlugin) \ } diff --git a/src/csync/csync_exclude.h b/src/csync/csync_exclude.h index 7d41a3326..bbb0a2cda 100644 --- a/src/csync/csync_exclude.h +++ b/src/csync/csync_exclude.h @@ -66,7 +66,7 @@ class OCSYNC_EXPORT ExcludedFiles : public QObject { Q_OBJECT public: - typedef std::tuple Version; + using Version = std::tuple; explicit ExcludedFiles(const QString &localPath = QStringLiteral("/")); ~ExcludedFiles(); diff --git a/src/csync/std/c_lib.h b/src/csync/std/c_lib.h index 13b9f1587..84f1004b2 100644 --- a/src/csync/std/c_lib.h +++ b/src/csync/std/c_lib.h @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include // NOLINT this is sometimes compiled in C mode -#include // NOLINT this is sometimes compiled in C mode +#include +#include #include "c_private.h" diff --git a/src/csync/std/c_private.h b/src/csync/std/c_private.h index bfad3b1b9..aaa41417f 100644 --- a/src/csync/std/c_private.h +++ b/src/csync/std/c_private.h @@ -39,7 +39,7 @@ #include #endif -#include // NOLINT this is sometimes compiled in C mode +#include #ifdef __MINGW32__ #ifndef S_IRGRP @@ -74,10 +74,10 @@ #ifdef _WIN32 -typedef struct stat64 csync_stat_t; // NOLINT this is sometimes compiled in C mode +using csync_stat_t = struct stat64; #define _FILE_OFFSET_BITS 64 #else -typedef struct stat csync_stat_t; // NOLINT this is sometimes compiled in C mode +using csync_stat_t = struct stat; #endif #ifndef O_NOATIME @@ -94,7 +94,7 @@ typedef struct stat csync_stat_t; // NOLINT this is sometimes compiled in C mode #endif #if defined _WIN32 && defined _UNICODE -typedef wchar_t mbchar_t; // NOLINT this is sometimes compiled in C mode +using mbchar_t = wchar_t; #define _topen _wopen #define _tdirent _wdirent #define _topendir _wopendir @@ -115,7 +115,7 @@ typedef wchar_t mbchar_t; // NOLINT this is sometimes compiled in C mod #define _tchdir _wchdir #define _tgetcwd _wgetcwd #else -typedef char mbchar_t; // NOLINT this is sometimes compiled in C mode +using mbchar_t = char; #define _tdirent dirent #define _topen open #define _topendir opendir diff --git a/src/csync/vio/csync_vio_local_unix.cpp b/src/csync/vio/csync_vio_local_unix.cpp index 5ebec53a8..1f41f42f1 100644 --- a/src/csync/vio/csync_vio_local_unix.cpp +++ b/src/csync/vio/csync_vio_local_unix.cpp @@ -74,7 +74,7 @@ int csync_vio_local_closedir(csync_vio_handle_t *dhandle) { std::unique_ptr csync_vio_local_readdir(csync_vio_handle_t *handle, OCC::Vfs *vfs) { - struct _tdirent *dirent = NULL; + struct _tdirent *dirent = nullptr; std::unique_ptr file_stat; do { diff --git a/src/gui/creds/httpcredentialsgui.cpp b/src/gui/creds/httpcredentialsgui.cpp index bb588fe0b..f8e3e5f9b 100644 --- a/src/gui/creds/httpcredentialsgui.cpp +++ b/src/gui/creds/httpcredentialsgui.cpp @@ -113,7 +113,7 @@ void HttpCredentialsGui::showDialog() + QLatin1String("
"); } - QInputDialog *dialog = new QInputDialog(); + auto *dialog = new QInputDialog(); dialog->setAttribute(Qt::WA_DeleteOnClose, true); dialog->setWindowTitle(tr("Enter Password")); dialog->setLabelText(msg); diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 7aef17696..742981195 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -648,8 +648,8 @@ void Folder::setVirtualFilesEnabled(bool enabled) _vfs->stop(); _vfs->unregisterFolder(); - disconnect(_vfs.data(), 0, this, 0); - disconnect(&_engine->syncFileStatusTracker(), 0, _vfs.data(), 0); + disconnect(_vfs.data(), nullptr, this, nullptr); + disconnect(&_engine->syncFileStatusTracker(), nullptr, _vfs.data(), nullptr); _vfs.reset(createVfsFromPlugin(newMode).release()); diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 87ecc4fb9..1e48367a1 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -1007,7 +1007,7 @@ Folder *FolderMan::addFolder(AccountState *accountState, const FolderDefinition auto vfs = createVfsFromPlugin(folderDefinition.virtualFilesMode); if (!vfs) { qCWarning(lcFolderMan) << "Could not load plugin for mode" << folderDefinition.virtualFilesMode; - return 0; + return nullptr; } auto folder = addFolderInternal(definition, accountState, std::move(vfs)); diff --git a/src/gui/guiutility.cpp b/src/gui/guiutility.cpp index 596f5a891..427ebb4b2 100644 --- a/src/gui/guiutility.cpp +++ b/src/gui/guiutility.cpp @@ -79,7 +79,6 @@ QString Utility::vfsCurrentAvailabilityText(VfsItemAvailability availability) case VfsItemAvailability::Mixed: return QCoreApplication::translate("utility", "Some available online only"); case VfsItemAvailability::AllDehydrated: - return QCoreApplication::translate("utility", "Available online only"); case VfsItemAvailability::OnlineOnly: return QCoreApplication::translate("utility", "Available online only"); } diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index 511d19b8b..1a06a5ec1 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -246,7 +246,7 @@ void SettingsDialog::accountAdded(AccountState *s) if (!brandingSingleAccount) { accountAction->setToolTip(s->account()->displayName()); - accountAction->setIconText(shortDisplayNameForSettings(s->account().data(), height * buttonSizeRatio)); + accountAction->setIconText(shortDisplayNameForSettings(s->account().data(), static_cast(height * buttonSizeRatio))); } _toolBar->insertAction(_toolBar->actions().at(0), accountAction); @@ -295,7 +295,7 @@ void SettingsDialog::slotAccountDisplayNameChanged() QString displayName = account->displayName(); action->setText(displayName); auto height = _toolBar->sizeHint().height(); - action->setIconText(shortDisplayNameForSettings(account, height * buttonSizeRatio)); + action->setIconText(shortDisplayNameForSettings(account, static_cast(height * buttonSizeRatio))); } } } diff --git a/src/libsync/creds/httpcredentials.cpp b/src/libsync/creds/httpcredentials.cpp index 21bb5559c..aa608759e 100644 --- a/src/libsync/creds/httpcredentials.cpp +++ b/src/libsync/creds/httpcredentials.cpp @@ -201,7 +201,7 @@ void HttpCredentials::fetchFromKeychainHelper() if (!_clientCertBundle.isEmpty()) { // New case (>=2.6): We have a bundle in the settings and read the password from // the keychain - ReadPasswordJob *job = new ReadPasswordJob(Theme::instance()->appName()); + auto job = new ReadPasswordJob(Theme::instance()->appName()); addSettingsToJob(_account, job); job->setInsecureFallback(false); job->setKey(keychainKey(_account->url().toString(), _user + clientCertPasswordC, _account->id())); @@ -263,7 +263,7 @@ void HttpCredentials::slotReadClientCertPasswordJobDone(QKeychain::Job *job) if (keychainUnavailableRetryLater(job)) return; - ReadPasswordJob *readJob = static_cast(job); + auto readJob = static_cast(job); if (readJob->error() == NoError) { _clientCertPassword = readJob->binaryData(); } else { diff --git a/src/libsync/creds/tokencredentials.cpp b/src/libsync/creds/tokencredentials.cpp index 2e443065e..85b5032ce 100644 --- a/src/libsync/creds/tokencredentials.cpp +++ b/src/libsync/creds/tokencredentials.cpp @@ -41,7 +41,7 @@ class TokenCredentialsAccessManager : public AccessManager { public: friend class TokenCredentials; - TokenCredentialsAccessManager(const TokenCredentials *cred, QObject *parent = 0) + TokenCredentialsAccessManager(const TokenCredentials *cred, QObject *parent = nullptr) : AccessManager(parent) , _cred(cred) { diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 3a1c311c1..120dc197a 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1296,9 +1296,8 @@ auto ProcessDirectoryJob::checkMovePermissions(RemotePermissions srcPerm, const bool destinationOK = true; bool destinationNewOK = true; if (destPerms.isNull()) { - } else if (isDirectory && !destPerms.hasPermission(RemotePermissions::CanAddSubDirectories)) { - destinationNewOK = false; - } else if (!isDirectory && !destPerms.hasPermission(RemotePermissions::CanAddFile)) { + } else if ((isDirectory && !destPerms.hasPermission(RemotePermissions::CanAddSubDirectories)) || + (!isDirectory && !destPerms.hasPermission(RemotePermissions::CanAddFile))) { destinationNewOK = false; } if (!isRename && !destinationNewOK) { diff --git a/src/libsync/discoveryphase.h b/src/libsync/discoveryphase.h index 20aab7311..7e31389c2 100644 --- a/src/libsync/discoveryphase.h +++ b/src/libsync/discoveryphase.h @@ -89,7 +89,7 @@ class DiscoverySingleLocalDirectoryJob : public QObject, public QRunnable { Q_OBJECT public: - explicit DiscoverySingleLocalDirectoryJob(const AccountPtr &account, const QString &localPath, OCC::Vfs *vfs, QObject *parent = 0); + explicit DiscoverySingleLocalDirectoryJob(const AccountPtr &account, const QString &localPath, OCC::Vfs *vfs, QObject *parent = nullptr); void run() Q_DECL_OVERRIDE; signals: diff --git a/src/libsync/localdiscoverytracker.cpp b/src/libsync/localdiscoverytracker.cpp index e7b42308b..2e8bc6716 100644 --- a/src/libsync/localdiscoverytracker.cpp +++ b/src/libsync/localdiscoverytracker.cpp @@ -22,9 +22,7 @@ using namespace OCC; Q_LOGGING_CATEGORY(lcLocalDiscoveryTracker, "sync.localdiscoverytracker", QtInfoMsg) -LocalDiscoveryTracker::LocalDiscoveryTracker() -{ -} +LocalDiscoveryTracker::LocalDiscoveryTracker() = default; void LocalDiscoveryTracker::addTouchedPath(const QString &relativePath) { diff --git a/src/libsync/localdiscoverytracker.h b/src/libsync/localdiscoverytracker.h index 1893e9402..b813ea97e 100644 --- a/src/libsync/localdiscoverytracker.h +++ b/src/libsync/localdiscoverytracker.h @@ -24,7 +24,7 @@ namespace OCC { class SyncFileItem; -typedef QSharedPointer SyncFileItemPtr; +using SyncFileItemPtr = QSharedPointer; /** * @brief Tracks files that must be rediscovered locally diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 52df7bd60..161b191df 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -205,7 +205,7 @@ void GETFileJob::slotMetaDataChanged() return; } - bool ok; + bool ok = false; _contentLength = reply()->header(QNetworkRequest::ContentLengthHeader).toLongLong(&ok); if (ok && _expectedContentLength != -1 && _contentLength != _expectedContentLength) { qCWarning(lcGetJob) << "We received a different content length than expected!" diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp index d2182df81..0cbb73ec6 100644 --- a/src/libsync/propagateupload.cpp +++ b/src/libsync/propagateupload.cpp @@ -441,12 +441,7 @@ UploadDevice::UploadDevice(const QString &fileName, qint64 start, qint64 size, B : _file(fileName) , _start(start) , _size(size) - , _read(0) , _bandwidthManager(bwm) - , _bandwidthQuota(0) - , _readWithProgress(0) - , _bandwidthLimited(false) - , _choked(false) { _bandwidthManager->registerUploadDevice(this); } diff --git a/src/libsync/propagateupload.h b/src/libsync/propagateupload.h index f9e239abd..d04f10172 100644 --- a/src/libsync/propagateupload.h +++ b/src/libsync/propagateupload.h @@ -73,10 +73,10 @@ private: // Bandwidth manager related QPointer _bandwidthManager; - qint64 _bandwidthQuota; - qint64 _readWithProgress; - bool _bandwidthLimited; // if _bandwidthQuota will be used - bool _choked; // if upload is paused (readData() will return 0) + qint64 _bandwidthQuota = 0; + qint64 _readWithProgress = 0; + bool _bandwidthLimited = false; // if _bandwidthQuota will be used + bool _choked = false; // if upload is paused (readData() will return 0) friend class BandwidthManager; public slots: void slotJobUploadProgress(qint64 sent, qint64 t); diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 834bfe74d..9c2dd8edc 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -563,7 +563,7 @@ void SyncEngine::startSync() // files with names that contain these. // It's important to respect the capability also for older servers -- the // version check doesn't make sense for custom servers. - invalidFilenamePattern = "[\\\\:?*\"<>|]"; + invalidFilenamePattern = R"([\\:?*"<>|])"; } if (!invalidFilenamePattern.isEmpty()) _discoveryPhase->_invalidFilenameRx = QRegExp(invalidFilenamePattern); @@ -589,12 +589,10 @@ void SyncEngine::startSync() void SyncEngine::slotFolderDiscovered(bool local, const QString &folder) { // Don't wanna overload the UI - if (!_lastUpdateProgressCallbackCall.isValid()) { - _lastUpdateProgressCallbackCall.start(); // first call - } else if (_lastUpdateProgressCallbackCall.elapsed() < 200) { - return; + if (!_lastUpdateProgressCallbackCall.isValid() || _lastUpdateProgressCallbackCall.elapsed() >= 200) { + _lastUpdateProgressCallbackCall.start(); // first call or enough elapsed time } else { - _lastUpdateProgressCallbackCall.start(); + return; } if (local) { @@ -1014,7 +1012,7 @@ void SyncEngine::abort() } else if (_discoveryPhase) { // Delete the discovery and all child jobs after ensuring // it can't finish and start the propagator - disconnect(_discoveryPhase.data(), 0, this, 0); + disconnect(_discoveryPhase.data(), nullptr, this, nullptr); _discoveryPhase.take()->deleteLater(); syncError(tr("Aborted")); diff --git a/src/libsync/vfs/suffix/vfs_suffix.cpp b/src/libsync/vfs/suffix/vfs_suffix.cpp index 357d5c88e..40a7519a7 100644 --- a/src/libsync/vfs/suffix/vfs_suffix.cpp +++ b/src/libsync/vfs/suffix/vfs_suffix.cpp @@ -27,9 +27,7 @@ VfsSuffix::VfsSuffix(QObject *parent) { } -VfsSuffix::~VfsSuffix() -{ -} +VfsSuffix::~VfsSuffix() = default; Vfs::Mode VfsSuffix::mode() const { diff --git a/test/csync/vio_tests/check_vio_ext.cpp b/test/csync/vio_tests/check_vio_ext.cpp index 209798988..193a9be47 100644 --- a/test/csync/vio_tests/check_vio_ext.cpp +++ b/test/csync/vio_tests/check_vio_ext.cpp @@ -61,7 +61,7 @@ static int wipe_testdir() } static int setup_testenv(void **state) { - int rc; + int rc = 0; rc = wipe_testdir(); assert_int_equal(rc, 0); @@ -80,7 +80,7 @@ static int setup_testenv(void **state) { assert_int_equal(rc, 0); /* --- initialize csync */ - statevar *mystate = new statevar; + auto mystate = new statevar; *state = mystate; return 0; } @@ -91,7 +91,7 @@ static void output( const char *text ) } static int teardown(void **state) { - int rc; + int rc = -1; output("================== Tearing down!\n"); @@ -110,7 +110,7 @@ static int teardown(void **state) { */ static void create_dirs( const char *path ) { - int rc; + int rc = -1; auto _mypath = QStringLiteral("%1/%2").arg(CSYNC_TEST_DIR, QString::fromUtf8(path)).toUtf8(); char *mypath = _mypath.data(); @@ -149,13 +149,13 @@ static void create_dirs( const char *path ) */ static void traverse_dir(void **state, const QString &dir, int *cnt) { - csync_vio_handle_t *dh; + csync_vio_handle_t *dh = nullptr; std::unique_ptr dirent; - statevar *sv = (statevar*) *state; + auto sv = (statevar*) *state; QByteArray subdir; QByteArray subdir_out; - int rc; - int is_dir; + int rc = -1; + int is_dir = 0; dh = csync_vio_local_opendir(dir); assert_non_null(dh); @@ -208,7 +208,7 @@ static void create_file( const char *path, const char *name, const char *content static void check_readdir_shorttree(void **state) { - statevar *sv = (statevar*) *state; + auto sv = (statevar*) *state; const char *t1 = "alibaba/und/die/vierzig/räuber/"; create_dirs( t1 ); @@ -230,7 +230,7 @@ static void check_readdir_shorttree(void **state) static void check_readdir_with_content(void **state) { - statevar *sv = (statevar*) *state; + auto sv = (statevar*) *state; int files_cnt = 0; const char *t1 = "warum/nur/40/Räuber/"; @@ -257,7 +257,7 @@ static void check_readdir_with_content(void **state) static void check_readdir_longtree(void **state) { - statevar *sv = (statevar*) *state; + auto sv = (statevar*) *state; /* Strange things here: Compilers only support strings with length of 4k max. * The expected result string is longer, so it needs to be split up in r1, r2 and r3 @@ -327,7 +327,7 @@ static void check_readdir_longtree(void **state) // https://github.com/owncloud/client/issues/3128 https://github.com/owncloud/client/issues/2777 static void check_readdir_bigunicode(void **state) { - statevar *sv = (statevar*) *state; + auto sv = (statevar*) *state; // 1: ? ASCII: 239 - EF // 2: ? ASCII: 187 - BB // 3: ? ASCII: 191 - BF @@ -362,5 +362,5 @@ int torture_run_tests(void) cmocka_unit_test_setup_teardown(check_readdir_bigunicode, setup_testenv, teardown), }; - return cmocka_run_group_tests(tests, NULL, NULL); + return cmocka_run_group_tests(tests, nullptr, nullptr); } diff --git a/test/mockserver/httpserver.h b/test/mockserver/httpserver.h index b408e4233..91bd5899e 100644 --- a/test/mockserver/httpserver.h +++ b/test/mockserver/httpserver.h @@ -18,7 +18,7 @@ class HttpServer : public QTcpServer { Q_OBJECT public: - HttpServer(qint16 port, QObject* parent = 0); + HttpServer(qint16 port, QObject* parent = nullptr); void incomingConnection(int socket); private slots: diff --git a/test/syncenginetestutils.cpp b/test/syncenginetestutils.cpp index 640cadf8d..aba75d6c4 100644 --- a/test/syncenginetestutils.cpp +++ b/test/syncenginetestutils.cpp @@ -8,6 +8,10 @@ #include "syncenginetestutils.h" +#include + + + PathComponents::PathComponents(const char *path) : PathComponents { QString::fromUtf8(path) } { @@ -374,7 +378,7 @@ FileInfo *FakePutReply::perform(FileInfo &remoteRootFileInfo, const QNetworkRequ fileInfo = remoteRootFileInfo.create(fileName, putPayload.size(), putPayload.at(0)); } fileInfo->lastModified = OCC::Utility::qDateTimeFromTime_t(request.rawHeader("X-OC-Mtime").toLongLong()); - remoteRootFileInfo.find(fileName, /*invalidate_etags=*/true); + remoteRootFileInfo.find(fileName, /*invalidateEtags=*/true); return fileInfo; } @@ -612,7 +616,7 @@ FileInfo *FakeChunkMoveReply::perform(FileInfo &uploadsFileInfo, FileInfo &remot QString source = getFilePathFromUrl(request.url()); Q_ASSERT(!source.isEmpty()); Q_ASSERT(source.endsWith(QLatin1String("/.file"))); - source = source.left(source.length() - qstrlen("/.file")); + source = source.left(source.length() - static_cast(qstrlen("/.file"))); auto sourceFolder = uploadsFileInfo.find(source); Q_ASSERT(sourceFolder); @@ -657,7 +661,7 @@ FileInfo *FakeChunkMoveReply::perform(FileInfo &uploadsFileInfo, FileInfo &remot fileInfo = remoteRootFileInfo.create(fileName, size, payload); } fileInfo->lastModified = OCC::Utility::qDateTimeFromTime_t(request.rawHeader("X-OC-Mtime").toLongLong()); - remoteRootFileInfo.find(fileName, /*invalidate_etags=*/true); + remoteRootFileInfo.find(fileName, /*invalidateEtags=*/true); return fileInfo; } @@ -800,7 +804,7 @@ QNetworkReply *FakeQNAM::createRequest(QNetworkAccessManager::Operation op, cons FileInfo &info = isUpload ? _uploadFileInfo : _remoteRootFileInfo; auto verb = request.attribute(QNetworkRequest::CustomVerbAttribute); - FakeReply *reply; + FakeReply *reply = nullptr; if (verb == QLatin1String("PROPFIND")) // Ignore outgoingData always returning somethign good enough, works for now. reply = new FakePropfindReply { info, op, request, this }; @@ -841,8 +845,8 @@ FakeFolder::FakeFolder(const FileInfo &fileTemplate) _account->setDavDisplayName(QStringLiteral("fakename")); _account->setServerVersion(QStringLiteral("10.0.0")); - _journalDb.reset(new OCC::SyncJournalDb(localPath() + QStringLiteral(".sync_test.db"))); - _syncEngine.reset(new OCC::SyncEngine(_account, localPath(), QString(), _journalDb.get())); + _journalDb = std::make_unique(localPath() + QStringLiteral(".sync_test.db")); + _syncEngine = std::make_unique(_account, localPath(), QString(), _journalDb.get()); // Ignore temporary files from the download. (This is in the default exclude list, but we don't load it) _syncEngine->excludedFiles().addManualExclude(QStringLiteral("]*.~*")); @@ -1026,5 +1030,4 @@ FakeReply::FakeReply(QObject *parent) } FakeReply::~FakeReply() -{ -} += default; diff --git a/test/testasyncop.cpp b/test/testasyncop.cpp index 29cfa1457..22b5c57f9 100644 --- a/test/testasyncop.cpp +++ b/test/testasyncop.cpp @@ -113,7 +113,7 @@ private slots: auto successCallback = [](TestCase *tc, const QNetworkRequest &request) { tc->pollRequest = [](TestCase *, const QNetworkRequest &) -> QNetworkReply * { std::abort(); }; // shall no longer be called FileInfo *info = tc->perform(); - QByteArray body = "{ \"status\":\"finished\", \"ETag\":\"\\\"" + info->etag + "\\\"\", \"fileId\":\"" + info->fileId + "\"}\n"; + QByteArray body = R"({ "status":"finished", "ETag":"\")" + info->etag + R"(\"", "fileId":")" + info->fileId + "\"}\n"; return new FakePayloadReply(QNetworkAccessManager::GetOperation, request, body, nullptr); }; // Callback that never finishes @@ -139,7 +139,7 @@ private slots: }; // Create a testcase by creating a file of a given size locally and assigning it a callback - auto insertFile = [&](const QString &file, int size, TestCase::PollRequest_t cb) { + auto insertFile = [&](const QString &file, qint64 size, TestCase::PollRequest_t cb) { fakeFolder.localModifier().insert(file, size); testCases[file] = { std::move(cb) }; }; diff --git a/test/testdownload.cpp b/test/testdownload.cpp index ec451e07b..80d85e4bd 100644 --- a/test/testdownload.cpp +++ b/test/testdownload.cpp @@ -26,7 +26,7 @@ public: { if (aborted) return 0; - return std::min(size, fakeSize) + QIODevice::bytesAvailable(); + return std::min(size, fakeSize) + QIODevice::bytesAvailable(); // NOLINT: This is intended to simulare the brokeness } qint64 readData(char *data, qint64 maxlen) override diff --git a/test/testexcludedfiles.cpp b/test/testexcludedfiles.cpp index f00683e88..c91b918fc 100644 --- a/test/testexcludedfiles.cpp +++ b/test/testexcludedfiles.cpp @@ -666,7 +666,7 @@ private slots: { extern void csync_exclude_expand_escapes(QByteArray &input); - QByteArray line = "keep \\' \\\" \\? \\\\ \\a \\b \\f \\n \\r \\t \\v \\z \\#"; + QByteArray line = R"(keep \' \" \? \\ \a \b \f \n \r \t \v \z \#)"; csync_exclude_expand_escapes(line); QVERIFY(0 == strcmp(line.constData(), "keep ' \" ? \\\\ \a \b \f \n \r \t \v \\z #")); diff --git a/test/testoauth.cpp b/test/testoauth.cpp index 506156a76..a366407db 100644 --- a/test/testoauth.cpp +++ b/test/testoauth.cpp @@ -310,14 +310,14 @@ private slots: if (redirectsDone == 0) { std::unique_ptr payload(new QBuffer()); payload->setData(""); - SlowFakePostReply *reply = new SlowFakePostReply(op, request, std::move(payload), this); + auto *reply = new SlowFakePostReply(op, request, std::move(payload), this); reply->redirectToPolicy = true; redirectsDone++; return reply; } else if (redirectsDone == 1) { std::unique_ptr payload(new QBuffer()); payload->setData(""); - SlowFakePostReply *reply = new SlowFakePostReply(op, request, std::move(payload), this); + auto *reply = new SlowFakePostReply(op, request, std::move(payload), this); reply->redirectToToken = true; redirectsDone++; return reply;