Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-tidy1
-rw-r--r--src/3rdparty/qtsingleapplication/qtlocalpeer.cpp2
-rw-r--r--src/cmd/cmd.cpp4
-rw-r--r--src/common/c_jhash.h12
-rw-r--r--src/common/filesystembase.cpp4
-rw-r--r--src/common/ownsql.cpp4
-rw-r--r--src/common/syncjournaldb.cpp2
-rw-r--r--src/csync/csync_util.cpp4
-rw-r--r--src/csync/std/c_alloc.c6
-rw-r--r--src/gui/accountsettings.cpp4
-rw-r--r--src/gui/folder.cpp19
-rw-r--r--src/gui/folderstatusmodel.cpp4
-rw-r--r--src/gui/folderwatcher_linux.cpp8
-rw-r--r--src/gui/generalsettings.cpp5
-rw-r--r--src/gui/ignorelisttablewidget.cpp2
-rw-r--r--src/gui/owncloudsetupwizard.cpp3
-rw-r--r--src/gui/selectivesyncdialog.cpp6
-rw-r--r--src/gui/settingsdialog.cpp2
-rw-r--r--src/gui/sharedialog.cpp2
-rw-r--r--src/gui/socketapi.cpp2
-rw-r--r--src/gui/updater/ocupdater.cpp2
-rw-r--r--src/gui/updater/updateinfo.cpp8
-rw-r--r--src/libsync/clientsideencryption.cpp8
-rw-r--r--src/libsync/cookiejar.cpp4
-rw-r--r--src/libsync/propagateremotemove.cpp2
-rw-r--r--src/libsync/propagatorjobs.cpp2
-rw-r--r--src/libsync/syncengine.cpp4
-rw-r--r--test/csync/csync_tests/check_csync_exclude.cpp8
-rw-r--r--test/csync/csync_tests/check_csync_update.cpp38
-rw-r--r--test/csync/csync_tests/check_csync_util.cpp2
-rw-r--r--test/csync/std_tests/check_std_c_alloc.c2
-rw-r--r--test/csync/std_tests/check_std_c_jhash.c67
-rw-r--r--test/csync/vio_tests/check_vio.cpp18
-rw-r--r--test/csync/vio_tests/check_vio_ext.cpp18
34 files changed, 163 insertions, 116 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 4dea40b2f..039e5d385 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,4 +1,5 @@
Checks: '-*,
+ cppcoreguidelines-init-variables,
modernize-make-shared,
modernize-redundant-void-arg,
modernize-replace-*,
diff --git a/src/3rdparty/qtsingleapplication/qtlocalpeer.cpp b/src/3rdparty/qtsingleapplication/qtlocalpeer.cpp
index f7229df5a..4630abd3f 100644
--- a/src/3rdparty/qtsingleapplication/qtlocalpeer.cpp
+++ b/src/3rdparty/qtsingleapplication/qtlocalpeer.cpp
@@ -154,7 +154,7 @@ void QtLocalPeer::receiveConnection()
}
QDataStream ds(socket);
QByteArray uMsg;
- quint32 remaining;
+ quint32 remaining = 0;
ds >> remaining;
uMsg.resize(remaining);
int got = 0;
diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp
index 8f8026a07..a56e9e2f7 100644
--- a/src/cmd/cmd.cpp
+++ b/src/cmd/cmd.cpp
@@ -288,7 +288,7 @@ void selectiveSyncFixup(OCC::SyncJournalDb *journal, const QStringList &newList)
return;
}
- bool ok;
+ bool ok = false;
auto oldBlackListSet = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok).toSet();
if (ok) {
@@ -418,7 +418,7 @@ int main(int argc, char **argv)
if (!options.proxy.isNull()) {
QString host;
int port = 0;
- bool ok;
+ bool ok = false;
QStringList pList = options.proxy.split(':');
if (pList.count() == 3) {
diff --git a/src/common/c_jhash.h b/src/common/c_jhash.h
index 97decf998..e765a3767 100644
--- a/src/common/c_jhash.h
+++ b/src/common/c_jhash.h
@@ -39,7 +39,7 @@
* have at least 1/4 probability of changing.
* If _c_mix() is run forward, every bit of c will change between 1/3 and
* 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.)
- * _c_mix() was built out of 36 single-cycle latency instructions in a
+ * _c_mix() was built out of 36 single-cycle latency instructions in a
* structure that could supported 2x parallelism, like so:
* a -= b;
* a -= c; x = (c>>13);
@@ -125,7 +125,10 @@
* avalanche. About 36+6len instructions.
*/
static inline uint32_t c_jhash(const uint8_t *k, uint32_t length, uint32_t initval) {
- uint32_t a,b,c,len;
+ uint32_t a = 0;
+ uint32_t b = 0;
+ uint32_t c = 0;
+ uint32_t len = 0;
/* Set up the internal state */
len = length;
@@ -184,7 +187,10 @@ static inline uint32_t c_jhash(const uint8_t *k, uint32_t length, uint32_t initv
* achieves avalanche. About 41+5len instructions.
*/
static inline uint64_t c_jhash64(const uint8_t *k, uint64_t length, uint64_t intval) {
- uint64_t a,b,c,len;
+ uint64_t a = 0;
+ uint64_t b = 0;
+ uint64_t c = 0;
+ uint64_t len = 0;
/* Set up the internal state */
len = length;
diff --git a/src/common/filesystembase.cpp b/src/common/filesystembase.cpp
index ddbb4be71..9a7401cda 100644
--- a/src/common/filesystembase.cpp
+++ b/src/common/filesystembase.cpp
@@ -179,7 +179,7 @@ bool FileSystem::uncheckedRenameReplace(const QString &originFileName,
QString *errorString)
{
#ifndef Q_OS_WIN
- bool success;
+ bool success = false;
QFile orig(originFileName);
// We want a rename that also overwites. QFile::rename does not overwite.
// Qt 5.1 has QSaveFile::renameOverwrite we could use.
@@ -396,7 +396,7 @@ QByteArray FileSystem::calcAdler32(const QString &filename)
unsigned int adler = adler32(0L, Z_NULL, 0);
if (file.open(QIODevice::ReadOnly)) {
- qint64 size;
+ qint64 size = 0;
while (!file.atEnd()) {
size = file.read(buf.data(), bufSize);
if (size > 0)
diff --git a/src/common/ownsql.cpp b/src/common/ownsql.cpp
index 937bcf918..f7151321a 100644
--- a/src/common/ownsql.cpp
+++ b/src/common/ownsql.cpp
@@ -253,7 +253,7 @@ int SqlQuery::prepare(const QByteArray &sql, bool allow_failure)
}
if (!_sql.isEmpty()) {
int n = 0;
- int rc;
+ int rc = 0;
do {
rc = sqlite3_prepare_v2(_db, _sql.constData(), -1, &_stmt, nullptr);
if ((rc == SQLITE_BUSY) || (rc == SQLITE_LOCKED)) {
@@ -306,7 +306,7 @@ bool SqlQuery::exec()
// Don't do anything for selects, that is how we use the lib :-|
if (!isSelect() && !isPragma()) {
- int rc, n = 0;
+ int rc = 0, n = 0;
do {
rc = sqlite3_step(_stmt);
if (rc == SQLITE_LOCKED) {
diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp
index 7a1de154d..ff4e352fe 100644
--- a/src/common/syncjournaldb.cpp
+++ b/src/common/syncjournaldb.cpp
@@ -811,7 +811,7 @@ QVector<QByteArray> SyncJournalDb::tableColumns(const QByteArray &table)
qint64 SyncJournalDb::getPHash(const QByteArray &file)
{
- int64_t h;
+ int64_t h = 0;
if (file.isEmpty()) {
return -1;
diff --git a/src/csync/csync_util.cpp b/src/csync/csync_util.cpp
index dd4ec9a1a..aabe1fdd5 100644
--- a/src/csync/csync_util.cpp
+++ b/src/csync/csync_util.cpp
@@ -88,7 +88,7 @@ const char *csync_instruction_str(enum csync_instructions_e instr)
void csync_memstat_check() {
int s = 0;
struct csync_memstat_s m;
- FILE* fp;
+ FILE* fp = nullptr;
/* get process memory stats */
fp = fopen("/proc/self/statm","r");
@@ -169,7 +169,7 @@ static const char short_months[12][4] = {
time_t oc_httpdate_parse( const char *date ) {
struct tm gmt;
char wkday[4], mon[4];
- int n;
+ int n = 0;
time_t result = 0;
memset(&gmt, 0, sizeof(struct tm));
diff --git a/src/csync/std/c_alloc.c b/src/csync/std/c_alloc.c
index b87a3836f..ab2f2a47a 100644
--- a/src/csync/std/c_alloc.c
+++ b/src/csync/std/c_alloc.c
@@ -62,7 +62,7 @@ void *c_realloc(void *ptr, size_t size) {
}
char *c_strdup(const char *str) {
- char *ret;
+ char *ret = NULL;
ret = (char *) c_malloc(strlen(str) + 1);
if (ret == NULL) {
return NULL;
@@ -72,8 +72,8 @@ char *c_strdup(const char *str) {
}
char *c_strndup(const char *str, size_t size) {
- char *ret;
- size_t len;
+ char *ret = NULL;
+ size_t len = 0;
len = strlen(str);
if (len > size) {
len = size;
diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp
index 7be63b3f9..5831078c5 100644
--- a/src/gui/accountsettings.cpp
+++ b/src/gui/accountsettings.cpp
@@ -1002,7 +1002,7 @@ void AccountSettings::slotAccountStateChanged()
if (state != AccountState::Connected) {
/* check if there are expanded root items, if so, close them */
- int i;
+ int i = 0;
for (i = 0; i < _model->rowCount(); ++i) {
if (_ui->_folderList->isExpanded(_model->index(i)))
_ui->_folderList->setExpanded(_model->index(i), false);
@@ -1077,7 +1077,7 @@ void AccountSettings::refreshSelectiveSyncStatus()
continue;
}
- bool ok;
+ bool ok = false;
auto undecidedList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, &ok);
QString p;
foreach (const auto &it, undecidedList) {
diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp
index f9cb8cfe0..655e6f0dd 100644
--- a/src/gui/folder.cpp
+++ b/src/gui/folder.cpp
@@ -903,20 +903,20 @@ void Folder::slotItemCompleted(const SyncFileItemPtr &item)
// add new directories or remove gone away dirs to the watcher
if (_folderWatcher && item->isDirectory()) {
- switch (item->_instruction) {
- case CSYNC_INSTRUCTION_NEW:
+ switch (item->_instruction) {
+ case CSYNC_INSTRUCTION_NEW:
_folderWatcher->addPath(path() + item->_file);
- break;
- case CSYNC_INSTRUCTION_REMOVE:
+ break;
+ case CSYNC_INSTRUCTION_REMOVE:
_folderWatcher->removePath(path() + item->_file);
- break;
- case CSYNC_INSTRUCTION_RENAME:
+ break;
+ case CSYNC_INSTRUCTION_RENAME:
_folderWatcher->removePath(path() + item->_file);
_folderWatcher->addPath(path() + item->destination());
- break;
+ break;
default:
break;
- }
+ }
}
// Success and failure of sync items adjust what the next sync is
@@ -953,7 +953,8 @@ void Folder::slotNewBigFolderDiscovered(const QString &newF, bool isExternal)
auto journal = journalDb();
// Add the entry to the blacklist if it is neither in the blacklist or whitelist already
- bool ok1, ok2;
+ bool ok1 = false;
+ bool ok2 = false;
auto blacklist = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok1);
auto whitelist = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, &ok2);
if (ok1 && ok2 && !blacklist.contains(newFolder) && !whitelist.contains(newFolder)) {
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp
index 8d0c2e881..59299a999 100644
--- a/src/gui/folderstatusmodel.cpp
+++ b/src/gui/folderstatusmodel.cpp
@@ -842,7 +842,7 @@ void FolderStatusModel::slotApplySelectiveSync()
}
auto folder = _folders.at(i)._folder;
- bool ok;
+ bool ok = false;
auto oldBlackList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok);
if (!ok) {
qCWarning(lcFolderStatus) << "Could not read selective sync list from db.";
@@ -1148,7 +1148,7 @@ void FolderStatusModel::slotSyncAllPendingBigFolders()
}
auto folder = _folders.at(i)._folder;
- bool ok;
+ bool ok = false;
auto undecidedList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, &ok);
if (!ok) {
qCWarning(lcFolderStatus) << "Could not read selective sync list from db.";
diff --git a/src/gui/folderwatcher_linux.cpp b/src/gui/folderwatcher_linux.cpp
index c048a552d..f1acf6cd3 100644
--- a/src/gui/folderwatcher_linux.cpp
+++ b/src/gui/folderwatcher_linux.cpp
@@ -126,10 +126,10 @@ void FolderWatcherPrivate::slotAddFolderRecursive(const QString &path)
void FolderWatcherPrivate::slotReceivedNotification(int fd)
{
- int len;
- struct inotify_event *event;
- int i;
- int error;
+ int len = 0;
+ struct inotify_event *event = nullptr;
+ int i = 0;
+ int error = 0;
QVarLengthArray<char, 2048> buffer(2048);
do {
diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp
index df7a9d7d0..40362cc64 100644
--- a/src/gui/generalsettings.cpp
+++ b/src/gui/generalsettings.cpp
@@ -111,7 +111,10 @@ GeneralSettings::GeneralSettings(QWidget *parent)
/* Set the left contents margin of the layout to zero to make the checkboxes
* align properly vertically , fixes bug #3758
*/
- int m0, m1, m2, m3;
+ int m0 = 0;
+ int m1 = 0;
+ int m2 = 0;
+ int m3 = 0;
_ui->horizontalLayout_3->getContentsMargins(&m0, &m1, &m2, &m3);
_ui->horizontalLayout_3->setContentsMargins(0, m1, m2, m3);
diff --git a/src/gui/ignorelisttablewidget.cpp b/src/gui/ignorelisttablewidget.cpp
index 7eaab4892..a9f5dae5b 100644
--- a/src/gui/ignorelisttablewidget.cpp
+++ b/src/gui/ignorelisttablewidget.cpp
@@ -108,7 +108,7 @@ void IgnoreListTableWidget::slotWriteIgnoreFile(const QString & file)
void IgnoreListTableWidget::slotAddPattern()
{
- bool okClicked;
+ bool okClicked = false;
QString pattern = QInputDialog::getText(this, tr("Add Ignore Pattern"),
tr("Add a new ignore pattern:"),
QLineEdit::Normal, QString(), &okClicked);
diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp
index 38f0f1980..bced047f2 100644
--- a/src/gui/owncloudsetupwizard.cpp
+++ b/src/gui/owncloudsetupwizard.cpp
@@ -616,8 +616,7 @@ bool OwncloudSetupWizard::ensureStartFromScratch(const QString &localFolder)
while (!renameOk) {
renameOk = FolderMan::instance()->startFromScratch(localFolder);
if (!renameOk) {
- QMessageBox::StandardButton but;
- but = QMessageBox::question(nullptr, tr("Folder rename failed"),
+ QMessageBox::StandardButton but = QMessageBox::question(nullptr, tr("Folder rename failed"),
tr("Can't remove and back up the folder because the folder or a file in it is open in another program."
" Please close the folder or file and hit retry or cancel the setup."),
QMessageBox::Retry | QMessageBox::Abort, QMessageBox::Retry);
diff --git a/src/gui/selectivesyncdialog.cpp b/src/gui/selectivesyncdialog.cpp
index 8ee353fbe..b30258317 100644
--- a/src/gui/selectivesyncdialog.cpp
+++ b/src/gui/selectivesyncdialog.cpp
@@ -433,7 +433,7 @@ SelectiveSyncDialog::SelectiveSyncDialog(AccountPtr account, Folder *folder, QWi
, _folder(folder)
, _okButton(nullptr) // defined in init()
{
- bool ok;
+ bool ok = false;
init(account);
QStringList selectiveSyncList = _folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok);
if (ok) {
@@ -463,7 +463,7 @@ void SelectiveSyncDialog::init(const AccountPtr &account)
auto *buttonBox = new QDialogButtonBox(Qt::Horizontal);
_okButton = buttonBox->addButton(QDialogButtonBox::Ok);
connect(_okButton, &QPushButton::clicked, this, &SelectiveSyncDialog::accept);
- QPushButton *button;
+ QPushButton *button = nullptr;
button = buttonBox->addButton(QDialogButtonBox::Cancel);
connect(button, &QAbstractButton::clicked, this, &QDialog::reject);
layout->addWidget(buttonBox);
@@ -472,7 +472,7 @@ void SelectiveSyncDialog::init(const AccountPtr &account)
void SelectiveSyncDialog::accept()
{
if (_folder) {
- bool ok;
+ bool ok = false;
auto oldBlackListSet = _folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok).toSet();
if (!ok) {
return;
diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp
index 51a42cb4f..f63533897 100644
--- a/src/gui/settingsdialog.cpp
+++ b/src/gui/settingsdialog.cpp
@@ -202,7 +202,7 @@ void SettingsDialog::accountAdded(AccountState *s)
auto height = _toolBar->sizeHint().height();
bool brandingSingleAccount = !Theme::instance()->multiAccount();
- QAction *accountAction;
+ QAction *accountAction = nullptr;
QImage avatar = s->account()->avatar();
const QString actionText = brandingSingleAccount ? tr("Account") : s->account()->displayName();
if (avatar.isNull()) {
diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp
index 7064a8ffd..240cc0a9e 100644
--- a/src/gui/sharedialog.cpp
+++ b/src/gui/sharedialog.cpp
@@ -309,7 +309,7 @@ void ShareDialog::slotCreateLinkShare()
void ShareDialog::slotLinkShareRequiresPassword()
{
- bool ok;
+ bool ok = false;
QString password = QInputDialog::getText(this,
tr("Password for share required"),
tr("Please enter a password for your link share:"),
diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp
index 8c0ec3912..3daa9bc23 100644
--- a/src/gui/socketapi.cpp
+++ b/src/gui/socketapi.cpp
@@ -558,7 +558,7 @@ private slots:
}
void passwordRequired() {
- bool ok;
+ bool ok = false;
QString password = QInputDialog::getText(nullptr,
tr("Password for share required"),
tr("Please enter a password for your link share:"),
diff --git a/src/gui/updater/ocupdater.cpp b/src/gui/updater/ocupdater.cpp
index af7b7c2ed..18ef64e20 100644
--- a/src/gui/updater/ocupdater.cpp
+++ b/src/gui/updater/ocupdater.cpp
@@ -229,7 +229,7 @@ void OCUpdater::slotVersionInfoArrived()
QString xml = QString::fromUtf8(reply->readAll());
- bool ok;
+ bool ok = false;
_updateInfo = UpdateInfo::parseString(xml, &ok);
if (ok) {
versionInfoArrived(_updateInfo);
diff --git a/src/gui/updater/updateinfo.cpp b/src/gui/updater/updateinfo.cpp
index 48ab68bae..8af312307 100644
--- a/src/gui/updater/updateinfo.cpp
+++ b/src/gui/updater/updateinfo.cpp
@@ -93,7 +93,7 @@ UpdateInfo UpdateInfo::parseFile(const QString &filename, bool *ok)
}
QString errorMsg;
- int errorLine, errorCol;
+ int errorLine = 0, errorCol = 0;
QDomDocument doc;
if (!doc.setContent(&file, false, &errorMsg, &errorLine, &errorCol)) {
qCCritical(lcUpdater) << errorMsg << " at " << errorLine << "," << errorCol;
@@ -102,7 +102,7 @@ UpdateInfo UpdateInfo::parseFile(const QString &filename, bool *ok)
return UpdateInfo();
}
- bool documentOk;
+ bool documentOk = false;
UpdateInfo c = parseElement(doc.documentElement(), &documentOk);
if (ok) {
*ok = documentOk;
@@ -113,7 +113,7 @@ UpdateInfo UpdateInfo::parseFile(const QString &filename, bool *ok)
UpdateInfo UpdateInfo::parseString(const QString &xml, bool *ok)
{
QString errorMsg;
- int errorLine, errorCol;
+ int errorLine = 0, errorCol = 0;
QDomDocument doc;
if (!doc.setContent(xml, false, &errorMsg, &errorLine, &errorCol)) {
qCCritical(lcUpdater) << errorMsg << " at " << errorLine << "," << errorCol;
@@ -122,7 +122,7 @@ UpdateInfo UpdateInfo::parseString(const QString &xml, bool *ok)
return UpdateInfo();
}
- bool documentOk;
+ bool documentOk = false;
UpdateInfo c = parseElement(doc.documentElement(), &documentOk);
if (ok) {
*ok = documentOk;
diff --git a/src/libsync/clientsideencryption.cpp b/src/libsync/clientsideencryption.cpp
index 6401a2269..0dd0ac555 100644
--- a/src/libsync/clientsideencryption.cpp
+++ b/src/libsync/clientsideencryption.cpp
@@ -235,7 +235,7 @@ namespace {
return res;
}
- QByteArray handleErrors(void)
+ QByteArray handleErrors()
{
Bio bioErrors;
ERR_print_errors(bioErrors); // This line is not printing anything.
@@ -305,6 +305,7 @@ QByteArray encryptPrivateKey(
QByteArray iv = generateRandom(12);
CipherCtx ctx;
+
/* Create and initialise the context */
if(!ctx) {
qCInfo(lcCse()) << "Error creating cipher";
@@ -424,7 +425,7 @@ QByteArray decryptPrivateKey(const QByteArray& key, const QByteArray& data) {
}
QByteArray ptext(cipherTXT.size() + 16, '\0');
- int plen;
+ int plen = 0;
/* Provide the message to be decrypted, and obtain the plaintext output.
* EVP_DecryptUpdate can be called multiple times if necessary
@@ -500,7 +501,7 @@ QByteArray decryptStringSymmetric(const QByteArray& key, const QByteArray& data)
}
QByteArray ptext(cipherTXT.size() + 16, '\0');
- int plen;
+ int plen = 0;
/* Provide the message to be decrypted, and obtain the plaintext output.
* EVP_DecryptUpdate can be called multiple times if necessary
@@ -544,6 +545,7 @@ QByteArray encryptStringSymmetric(const QByteArray& key, const QByteArray& data)
QByteArray iv = generateRandom(16);
CipherCtx ctx;
+
/* Create and initialise the context */
if(!ctx) {
qCInfo(lcCse()) << "Error creating cipher";
diff --git a/src/libsync/cookiejar.cpp b/src/libsync/cookiejar.cpp
index 9824aab5d..5e28c1b62 100644
--- a/src/libsync/cookiejar.cpp
+++ b/src/libsync/cookiejar.cpp
@@ -43,13 +43,13 @@ QDataStream &operator>>(QDataStream &stream, QList<QNetworkCookie> &list)
{
list.clear();
- quint32 version;
+ quint32 version = 0;
stream >> version;
if (version != JAR_VERSION)
return stream;
- quint32 count;
+ quint32 count = 0;
stream >> count;
for (quint32 i = 0; i < count; ++i) {
QByteArray value;
diff --git a/src/libsync/propagateremotemove.cpp b/src/libsync/propagateremotemove.cpp
index 99943ed87..0e106d851 100644
--- a/src/libsync/propagateremotemove.cpp
+++ b/src/libsync/propagateremotemove.cpp
@@ -180,7 +180,7 @@ void PropagateRemoteMove::finalize()
bool PropagateRemoteMove::adjustSelectiveSync(SyncJournalDb *journal, const QString &from_, const QString &to_)
{
- bool ok;
+ bool ok = false;
// We only care about preserving the blacklist. The white list should anyway be empty.
// And the undecided list will be repopulated on the next sync, if there is anything too big.
QStringList list = journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok);
diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp
index 4e019d257..3ec7e1a03 100644
--- a/src/libsync/propagatorjobs.cpp
+++ b/src/libsync/propagatorjobs.cpp
@@ -64,7 +64,7 @@ bool PropagateLocalRemove::removeRecursively(const QString &path)
while (di.hasNext()) {
di.next();
const QFileInfo &fi = di.fileInfo();
- bool ok;
+ bool ok = false;
// The use of isSymLink here is okay:
// we never want to go into this branch for .lnk files
bool isDir = fi.isDir() && !fi.isSymLink() && !FileSystem::isJunction(fi.absoluteFilePath());
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index 6f7fca1cf..7c8efd5c1 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -858,7 +858,7 @@ void SyncEngine::startSync()
return shouldDiscoverLocally(path);
};
- bool ok;
+ bool ok = false;
auto selectiveSyncBlackList = _journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok);
if (ok) {
bool usingSelectiveSync = (!selectiveSyncBlackList.isEmpty());
@@ -1302,7 +1302,7 @@ QString SyncEngine::adjustRenamedPath(const QString &original)
*/
void SyncEngine::checkForPermission(SyncFileItemVector &syncItems)
{
- bool selectiveListOk;
+ bool selectiveListOk = false;
auto selectiveSyncBlackList = _journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &selectiveListOk);
std::sort(selectiveSyncBlackList.begin(), selectiveSyncBlackList.end());
SyncFileItemPtr needle;
diff --git a/test/csync/csync_tests/check_csync_exclude.cpp b/test/csync/csync_tests/check_csync_exclude.cpp
index 07ec665a8..8425877b1 100644
--- a/test/csync/csync_tests/check_csync_exclude.cpp
+++ b/test/csync/csync_tests/check_csync_exclude.cpp
@@ -37,7 +37,7 @@ class ExcludedFilesTest
public:
static int setup(void **state) {
- CSYNC *csync;
+ CSYNC *csync = nullptr;
csync = new CSYNC("/tmp/check_csync1", new OCC::SyncJournalDb(""));
excludedFiles = new ExcludedFiles;
@@ -49,7 +49,7 @@ static int setup(void **state) {
}
static int setup_init(void **state) {
- CSYNC *csync;
+ CSYNC *csync = nullptr;
csync = new CSYNC("/tmp/check_csync1", new OCC::SyncJournalDb(""));
excludedFiles = new ExcludedFiles;
@@ -74,7 +74,7 @@ static int setup_init(void **state) {
static int teardown(void **state) {
CSYNC *csync = (CSYNC*)*state;
- int rc;
+ int rc = 0;
auto statedb = csync->statedb;
delete csync;
@@ -272,7 +272,7 @@ static void check_csync_excluded_per_dir(void **)
#define FOO_DIR "/tmp/check_csync1/foo"
#define FOO_EXCLUDE_LIST FOO_DIR "/.sync-exclude.lst"
- int rc;
+ int rc = 0;
rc = system("mkdir -p " FOO_DIR);
assert_int_equal(rc, 0);
FILE *fh = fopen(FOO_EXCLUDE_LIST, "w");
diff --git a/test/csync/csync_tests/check_csync_update.cpp b/test/csync/csync_tests/check_csync_update.cpp
index b4eca074d..11acf896a 100644
--- a/test/csync/csync_tests/check_csync_update.cpp
+++ b/test/csync/csync_tests/check_csync_update.cpp
@@ -82,7 +82,7 @@ static void statedb_insert_metadata(sqlite3 *db)
0,
"4711");
- char *errmsg;
+ char *errmsg = nullptr;
rc = sqlite3_exec(db, stmt, NULL, NULL, &errmsg);
sqlite3_free(stmt);
assert_int_equal( rc, SQLITE_OK );
@@ -91,8 +91,8 @@ static void statedb_insert_metadata(sqlite3 *db)
static int setup(void **state)
{
- CSYNC *csync;
- int rc;
+ CSYNC *csync = nullptr;
+ int rc = 0;
unlink(TESTDB);
rc = system("mkdir -p /tmp/check_csync");
@@ -101,7 +101,7 @@ static int setup(void **state)
assert_int_equal(rc, 0);
/* Create a new db with metadata */
- sqlite3 *db;
+ sqlite3 *db = nullptr;
rc = sqlite3_open(TESTDB, &db);
statedb_create_metadata_table(db);
if( firstrun ) {
@@ -120,8 +120,8 @@ static int setup(void **state)
static int setup_ftw(void **state)
{
- CSYNC *csync;
- int rc;
+ CSYNC *csync = nullptr;
+ int rc = 0;
rc = system("mkdir -p /tmp/check_csync");
assert_int_equal(rc, 0);
@@ -159,7 +159,7 @@ static int teardown(void **state)
}
static int teardown_rm(void **state) {
- int rc;
+ int rc = 0;
teardown(state);
@@ -177,7 +177,7 @@ static std::unique_ptr<csync_file_stat_t> create_fstat(const char *name,
time_t mtime)
{
std::unique_ptr<csync_file_stat_t> fs(new csync_file_stat_t);
- time_t t;
+ time_t t = 0;
if (name && *name) {
fs->path = name;
@@ -217,9 +217,9 @@ static int failing_fn(CSYNC *ctx,
static void check_csync_detect_update(void **state)
{
CSYNC *csync = (CSYNC*)*state;
- csync_file_stat_t *st;
+ csync_file_stat_t *st = nullptr;
std::unique_ptr<csync_file_stat_t> fs;
- int rc;
+ int rc = 0;
fs = create_fstat("file.txt", 0, 1217597845);
@@ -240,9 +240,9 @@ static void check_csync_detect_update(void **state)
static void check_csync_detect_update_db_none(void **state)
{
CSYNC *csync = (CSYNC*)*state;
- csync_file_stat_t *st;
+ csync_file_stat_t *st = nullptr;
std::unique_ptr<csync_file_stat_t> fs;
- int rc;
+ int rc = 0;
fs = create_fstat("file.txt", 0, 1217597845);
@@ -261,9 +261,9 @@ static void check_csync_detect_update_db_none(void **state)
static void check_csync_detect_update_db_eval(void **state)
{
CSYNC *csync = (CSYNC*)*state;
- csync_file_stat_t *st;
+ csync_file_stat_t *st = nullptr;
std::unique_ptr<csync_file_stat_t> fs;
- int rc;
+ int rc = 0;
fs = create_fstat("file.txt", 0, 42);
@@ -307,9 +307,9 @@ static void check_csync_detect_update_db_rename(void **state)
static void check_csync_detect_update_db_new(void **state)
{
CSYNC *csync = (CSYNC*)*state;
- csync_file_stat_t *st;
+ csync_file_stat_t *st = nullptr;
std::unique_ptr<csync_file_stat_t> fs;
- int rc;
+ int rc = 0;
fs = create_fstat("file.txt", 42000, 0);
@@ -328,7 +328,7 @@ static void check_csync_detect_update_db_new(void **state)
static void check_csync_ftw(void **state)
{
CSYNC *csync = (CSYNC*)*state;
- int rc;
+ int rc = 0;
rc = csync_ftw(csync, "/tmp", csync_walker, MAX_DEPTH);
assert_int_equal(rc, 0);
@@ -337,7 +337,7 @@ static void check_csync_ftw(void **state)
static void check_csync_ftw_empty_uri(void **state)
{
CSYNC *csync = (CSYNC*)*state;
- int rc;
+ int rc = 0;
rc = csync_ftw(csync, "", csync_walker, MAX_DEPTH);
assert_int_equal(rc, -1);
@@ -346,7 +346,7 @@ static void check_csync_ftw_empty_uri(void **state)
static void check_csync_ftw_failing_fn(void **state)
{
CSYNC *csync = (CSYNC*)*state;
- int rc;
+ int rc = 0;
rc = csync_ftw(csync, "/tmp", failing_fn, MAX_DEPTH);
assert_int_equal(rc, -1);
diff --git a/test/csync/csync_tests/check_csync_util.cpp b/test/csync/csync_tests/check_csync_util.cpp
index eb1e613ea..11fae6c09 100644
--- a/test/csync/csync_tests/check_csync_util.cpp
+++ b/test/csync/csync_tests/check_csync_util.cpp
@@ -23,7 +23,7 @@
static void check_csync_instruction_str(void **state)
{
- const char *str;
+ const char *str = nullptr;
(void) state; /* unused */
diff --git a/test/csync/std_tests/check_std_c_alloc.c b/test/csync/std_tests/check_std_c_alloc.c
index bcdf7e1cf..bf9a31538 100644
--- a/test/csync/std_tests/check_std_c_alloc.c
+++ b/test/csync/std_tests/check_std_c_alloc.c
@@ -41,7 +41,7 @@ static void check_c_malloc(void **state)
static void check_c_malloc_zero(void **state)
{
- void *p;
+ void *p = NULL;
(void) state; /* unused */
diff --git a/test/csync/std_tests/check_std_c_jhash.c b/test/csync/std_tests/check_std_c_jhash.c
index de7d8e7d5..88fc0734f 100644
--- a/test/csync/std_tests/check_std_c_jhash.c
+++ b/test/csync/std_tests/check_std_c_jhash.c
@@ -16,10 +16,17 @@
static void check_c_jhash_trials(void **state)
{
uint8_t qa[MAXLEN+1], qb[MAXLEN+2], *a = &qa[0], *b = &qb[1];
- uint32_t c[HASHSTATE], d[HASHSTATE], i, j=0, k, l, m, z;
+ uint32_t c[HASHSTATE];
+ uint32_t d[HASHSTATE];
+ uint32_t i = 0;
+ uint32_t j = 0;
+ uint32_t k = 0;
+ uint32_t l = 0;
+ uint32_t m = 0;
+ uint32_t z = 0;
uint32_t e[HASHSTATE],f[HASHSTATE],g[HASHSTATE],h[HASHSTATE];
uint32_t x[HASHSTATE],y[HASHSTATE];
- uint32_t hlen;
+ uint32_t hlen = 0;
(void) state; /* unused */
@@ -75,14 +82,20 @@ static void check_c_jhash_trials(void **state)
static void check_c_jhash_alignment_problems(void **state)
{
- uint32_t test;
- uint8_t buf[MAXLEN+20], *b;
- uint32_t len;
+ uint32_t test = 0;
+ uint8_t buf[MAXLEN+20];
+ uint8_t *b = NULL;
+ uint32_t len = 0;
uint8_t q[] = "This is the time for all good men to come to the aid of their country";
uint8_t qq[] = "xThis is the time for all good men to come to the aid of their country";
uint8_t qqq[] = "xxThis is the time for all good men to come to the aid of their country";
uint8_t qqqq[] = "xxxThis is the time for all good men to come to the aid of their country";
- uint32_t h,i,j,ref,x,y;
+ uint32_t h = 0;
+ uint32_t i = 0;
+ uint32_t j = 0;
+ uint32_t ref = 0;
+ uint32_t x = 0;
+ uint32_t y = 0;
(void) state; /* unused */
@@ -110,7 +123,9 @@ static void check_c_jhash_alignment_problems(void **state)
static void check_c_jhash_null_strings(void **state)
{
uint8_t buf[1];
- uint32_t h, i, t;
+ uint32_t h = 0;
+ uint32_t i = 0;
+ uint32_t t = 0;
(void) state; /* unused */
@@ -126,11 +141,22 @@ static void check_c_jhash_null_strings(void **state)
static void check_c_jhash64_trials(void **state)
{
uint8_t qa[MAXLEN + 1], qb[MAXLEN + 2];
- uint8_t *a, *b;
- uint64_t c[HASHSTATE], d[HASHSTATE], i, j=0, k, l, m, z;
- uint64_t e[HASHSTATE],f[HASHSTATE],g[HASHSTATE],h[HASHSTATE];
- uint64_t x[HASHSTATE],y[HASHSTATE];
- uint64_t hlen;
+ uint8_t *a = NULL, *b = NULL;
+ uint64_t c[HASHSTATE];
+ uint64_t d[HASHSTATE];
+ uint64_t i = 0;
+ uint64_t j=0;
+ uint64_t k = 0;
+ uint64_t l = 0;
+ uint64_t m = 0;
+ uint64_t z = 0;
+ uint64_t e[HASHSTATE];
+ uint64_t f[HASHSTATE];
+ uint64_t g[HASHSTATE];
+ uint64_t h[HASHSTATE];
+ uint64_t x[HASHSTATE];
+ uint64_t y[HASHSTATE];
+ uint64_t hlen = 0;
(void) state; /* unused */
@@ -200,8 +226,9 @@ static void check_c_jhash64_trials(void **state)
static void check_c_jhash64_alignment_problems(void **state)
{
- uint8_t buf[MAXLEN+20], *b;
- uint64_t len;
+ uint8_t buf[MAXLEN+20];
+ uint8_t *b = NULL;
+ uint64_t len = 0;
uint8_t q[] = "This is the time for all good men to come to the aid of their country";
uint8_t qq[] = "xThis is the time for all good men to come to the aid of their country";
uint8_t qqq[] = "xxThis is the time for all good men to come to the aid of their country";
@@ -210,7 +237,13 @@ static void check_c_jhash64_alignment_problems(void **state)
uint8_t oo[] = "xxxxxThis is the time for all good men to come to the aid of their country";
uint8_t ooo[] = "xxxxxxThis is the time for all good men to come to the aid of their country";
uint8_t oooo[] = "xxxxxxxThis is the time for all good men to come to the aid of their country";
- uint64_t h,i,j,ref,t,x,y;
+ uint64_t h = 0;
+ uint64_t i = 0;
+ uint64_t j = 0;
+ uint64_t ref = 0;
+ uint64_t t = 0;
+ uint64_t x = 0;
+ uint64_t y = 0;
(void) state; /* unused */
@@ -261,7 +294,9 @@ static void check_c_jhash64_alignment_problems(void **state)
static void check_c_jhash64_null_strings(void **state)
{
uint8_t buf[1];
- uint64_t h, i, t;
+ uint64_t h = 0;
+ uint64_t i = 0;
+ uint64_t t = 0;
(void) state; /* unused */
diff --git a/test/csync/vio_tests/check_vio.cpp b/test/csync/vio_tests/check_vio.cpp
index 884accf43..79e28ab1c 100644
--- a/test/csync/vio_tests/check_vio.cpp
+++ b/test/csync/vio_tests/check_vio.cpp
@@ -41,8 +41,8 @@ static char wd_buffer[WD_BUFFER_SIZE];
static int setup(void **state)
{
- CSYNC *csync;
- int rc;
+ CSYNC *csync = nullptr;
+ int rc = 0;
assert_non_null(getcwd(wd_buffer, WD_BUFFER_SIZE));
@@ -58,7 +58,7 @@ static int setup(void **state)
}
static int setup_dir(void **state) {
- int rc;
+ int rc = 0;
mbchar_t *dir = c_utf8_path_to_locale(CSYNC_TEST_DIR);
setup(state);
@@ -76,7 +76,7 @@ static int setup_dir(void **state) {
static int teardown(void **state) {
CSYNC *csync = (CSYNC*)*state;
- int rc;
+ int rc = 0;
auto statedb = csync->statedb;
delete csync;
@@ -100,8 +100,8 @@ static int teardown(void **state) {
static void check_csync_vio_opendir(void **state)
{
CSYNC *csync = (CSYNC*)*state;
- csync_vio_handle_t *dh;
- int rc;
+ csync_vio_handle_t *dh = nullptr;
+ int rc = 0;
dh = csync_vio_opendir(csync, CSYNC_TEST_DIR);
assert_non_null(dh);
@@ -113,8 +113,8 @@ static void check_csync_vio_opendir(void **state)
static void check_csync_vio_opendir_perm(void **state)
{
CSYNC *csync = (CSYNC*)*state;
- csync_vio_handle_t *dh;
- int rc;
+ csync_vio_handle_t *dh = nullptr;
+ int rc = 0;
mbchar_t *dir = c_utf8_path_to_locale(CSYNC_TEST_DIR);
assert_non_null(dir);
@@ -133,7 +133,7 @@ static void check_csync_vio_opendir_perm(void **state)
static void check_csync_vio_closedir_null(void **state)
{
CSYNC *csync = (CSYNC*)*state;
- int rc;
+ int rc = 0;
rc = csync_vio_closedir(csync, NULL);
assert_int_equal(rc, -1);
diff --git a/test/csync/vio_tests/check_vio_ext.cpp b/test/csync/vio_tests/check_vio_ext.cpp
index f0e772956..e73c42424 100644
--- a/test/csync/vio_tests/check_vio_ext.cpp
+++ b/test/csync/vio_tests/check_vio_ext.cpp
@@ -76,7 +76,7 @@ static int wipe_testdir()
}
static int setup_testenv(void **state) {
- int rc;
+ int rc = 0;
rc = wipe_testdir();
assert_int_equal(rc, 0);
@@ -120,7 +120,7 @@ static void output( const char *text )
static int teardown(void **state) {
statevar *sv = (statevar*) *state;
CSYNC *csync = sv->csync;
- int rc;
+ int rc = 0;
output("================== Tearing down!\n");
@@ -143,7 +143,7 @@ static int teardown(void **state) {
*/
static void create_dirs( const char *path )
{
- int rc;
+ int rc = 0;
char *mypath = (char*)c_malloc( 2+strlen(CSYNC_TEST_DIR)+strlen(path));
*mypath = '\0';
strcat(mypath, CSYNC_TEST_DIR);
@@ -185,14 +185,14 @@ static void create_dirs( const char *path )
*/
static void traverse_dir(void **state, const char *dir, int *cnt)
{
- csync_vio_handle_t *dh;
+ csync_vio_handle_t *dh = nullptr;
std::unique_ptr<csync_file_stat_t> dirent;
statevar *sv = (statevar*) *state;
CSYNC *csync = sv->csync;
- char *subdir;
- char *subdir_out;
- int rc;
- int is_dir;
+ char *subdir = nullptr;
+ char *subdir_out = nullptr;
+ int rc = 0;
+ int is_dir = 0;
/* Format: Smuggle in the C: for unix platforms as its urgently needed
* on Windows and the test can be nicely cross platform this way. */
@@ -292,7 +292,7 @@ static void create_file( const char *path, const char *name, const char *content
strcpy(filepath, path);
strcat(filepath, name);
- FILE *sink;
+ FILE *sink = nullptr;
sink = fopen(filepath,"w");
fprintf (sink, "we got: %s",content);