Do not declare local variables without an initial value.
authorCamila San <hello@camila.codes>
Fri, 29 May 2020 13:07:05 +0000 (15:07 +0200)
committerKevin Ottens (Rebase PR Action) <er-vin@users.noreply.github.com>
Wed, 3 Jun 2020 07:50:40 +0000 (07:50 +0000)
Signed-off-by: Camila San <hello@camila.codes>
34 files changed:
.clang-tidy
src/3rdparty/qtsingleapplication/qtlocalpeer.cpp
src/cmd/cmd.cpp
src/common/c_jhash.h
src/common/filesystembase.cpp
src/common/ownsql.cpp
src/common/syncjournaldb.cpp
src/csync/csync_util.cpp
src/csync/std/c_alloc.c
src/gui/accountsettings.cpp
src/gui/folder.cpp
src/gui/folderstatusmodel.cpp
src/gui/folderwatcher_linux.cpp
src/gui/generalsettings.cpp
src/gui/ignorelisttablewidget.cpp
src/gui/owncloudsetupwizard.cpp
src/gui/selectivesyncdialog.cpp
src/gui/settingsdialog.cpp
src/gui/sharedialog.cpp
src/gui/socketapi.cpp
src/gui/updater/ocupdater.cpp
src/gui/updater/updateinfo.cpp
src/libsync/clientsideencryption.cpp
src/libsync/cookiejar.cpp
src/libsync/propagateremotemove.cpp
src/libsync/propagatorjobs.cpp
src/libsync/syncengine.cpp
test/csync/csync_tests/check_csync_exclude.cpp
test/csync/csync_tests/check_csync_update.cpp
test/csync/csync_tests/check_csync_util.cpp
test/csync/std_tests/check_std_c_alloc.c
test/csync/std_tests/check_std_c_jhash.c
test/csync/vio_tests/check_vio.cpp
test/csync/vio_tests/check_vio_ext.cpp

index 4dea40b2f445902afc5ed0f949bc109d6c5fecd2..039e5d385625767902f99c31b25342c39589bd9c 100644 (file)
@@ -1,4 +1,5 @@
 Checks: '-*,
+    cppcoreguidelines-init-variables,
     modernize-make-shared,
     modernize-redundant-void-arg,
     modernize-replace-*,
index f7229df5afc9fc0a4097b821e6f2aa07939e2dea..4630abd3f3c0c51cfe3d43f4b39614c703f3134b 100644 (file)
@@ -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;
index 8f8026a07cf7778cb103f3a9f3d47a1a5f7c32ef..a56e9e2f7758658128ad673f34ee1d8a975e65f8 100644 (file)
@@ -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) {
index 97decf99802f969f8310d63abad3c1416d5a3677..e765a3767321435a075c34a608337993d390323c 100644 (file)
@@ -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);
  *            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;
index ddbb4be714691a5d5701952e22bf18b08420abdb..9a7401cda5b803c6dc8e00df94b0dbf064ae41e2 100644 (file)
@@ -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)
index 937bcf9188d3946d9be50bb4aabead5aeca2ce55..f7151321a8bb02ab25f6cd419dce2b3abbfad930 100644 (file)
@@ -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) {
index 7a1de154d8b070041ff24d4de86c1ae3474937c0..ff4e352fe2ae847e4d2633261a7feeaa798e2e39 100644 (file)
@@ -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;
index dd4ec9a1ad6876105ddf74304631962c8c5450e4..aabe1fdd5c55c1a4b2c07d57afaa4725c40d3f29 100644 (file)
@@ -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));
index b87a3836f9a49700800869c2699c57bfa7a0b0d0..ab2f2a47ac850da094f34786b2adc06a3b0ae23d 100644 (file)
@@ -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;
index 7be63b3f913f17ab2beea8ffe25da7cfc75baeda..5831078c5395ffcd61496ff0b72e21e8a66be346 100644 (file)
@@ -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) {
index f9cb8cfe00f6331738ead7051ecebf2fe9bb2f2c..655e6f0dd41cfdf92055028045278b0d9664fc0a 100644 (file)
@@ -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)) {
index 8d0c2e8816b8a75167ecdc4ce1549416a9145ba4..59299a999545a59affcdaa11060da2944e6b3828 100644 (file)
@@ -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.";
index c048a552daafd8442c033470438bcf6fdd5da436..f1acf6cd307af175ab598abee526276c3aef95c3 100644 (file)
@@ -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 {
index df7a9d7d0353de5e0ad39f59fab3bf01c9d07af6..40362cc64c46b12f530ec66d27e19a98b5be2e9c 100644 (file)
@@ -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);
 
index 7eaab489204b35bc68a323761e3314117af087cf..a9f5dae5b8e69289d47efe7b7a59f67d1d4818d3 100644 (file)
@@ -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);
index 38f0f1980878edbe5b5b3a62968a2f1f4997a1f9..bced047f2bed38800a2acead9b02ad5cef32bee3 100644 (file)
@@ -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);
index 8ee353fbe9d432108852deb5f05acb2e29779c32..b302583173f90f77feff197dfb701e51528ff67e 100644 (file)
@@ -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;
index 51a42cb4f39191e696607baf1cea02141a4d12ef..f63533897d9ff6f4b595f8ac3aca8b111074874a 100644 (file)
@@ -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()) {
index 7064a8ffd679f8e94cb9ab1e27b1fb3d1ded748a..240cc0a9e8cf4c5f345d8daa9867b6bf68aeac65 100644 (file)
@@ -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:"),
index 8c0ec3912235ec1d1b7e33fca833f4be80b4081a..3daa9bc23eab9f2943b8a1e036aec71bd54ad7c4 100644 (file)
@@ -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:"),
index af7b7c2ed80f823baa045dc7cea2fbae96df4035..18ef64e20fc1dd86f1fc416416d035228891f988 100644 (file)
@@ -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);
index 48ab68bae44747634f5da88e1c608a642af58680..8af3123075153b58b3cb6dd9b093269fcaada2be 100644 (file)
@@ -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;
index 6401a22695940cfed1ac6cc916441552a7c722de..0dd0ac55552edd42a4bf6c1e629400dcd4c2ba31 100644 (file)
@@ -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";
index 9824aab5d2501a8c821a2121100158693bbdba84..5e28c1b627b9f48c01eedea2bb0b0de4a56858ab 100644 (file)
@@ -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;
index 99943ed87cf4841354661e050897ebb0f1e5a62f..0e106d851cd16ea1d8edf91aeb0481fdc0404cd0 100644 (file)
@@ -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);
index 4e019d2571396758d75e1f418fa3700f2e51af0b..3ec7e1a031fb9c46540c5b810ce6770115566c82 100644 (file)
@@ -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());
index 6f7fca1cf6ecd519713a78f701bed3066e398423..7c8efd5c1bee2b30f6c93a5923a6ded9e6bb0aa1 100644 (file)
@@ -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;
index 07ec665a8c0b078c13d0bf71d4aebd5ee296b887..8425877b1eacf70ce62989f4ede0a45fbe8fa501 100644 (file)
@@ -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");
index b4eca074dde10204ee48367d1581022663200dfc..11acf896a582e5cc689b2537bd67e325578eb496 100644 (file)
@@ -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);
index eb1e613eaf6fbae07037216b72f1c66ad85cccd5..11fae6c09f8fdc04a1422b840278744830454c60 100644 (file)
@@ -23,7 +23,7 @@
 
 static void check_csync_instruction_str(void **state)
 {
-  const char *str;
+  const char *str = nullptr;
 
   (void) state; /* unused */
 
index bcdf7e1cfee34b0a43efe60dda3886edd07b7a5a..bf9a31538ffcd9056b2baf2a28821ca93954163e 100644 (file)
@@ -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 */
 
index de7d8e7d508f1a4db60e12db8e656b8b4b39cb0a..88fc0734f297de8c12293cc185fca46875c696db 100644 (file)
 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 */
 
index 884accf43d8e4b6e4038a135135985ed36418988..79e28ab1c2366b5e371ce220d354780f944953c5 100644 (file)
@@ -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);
index f0e7729568eac989e705a7db0929563a68230729..e73c424249396aca4ed039887191163f16ed473f 100644 (file)
@@ -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);