Merge pull request #2047 from nextcloud/clang-cppcoreguidelines-init-var

Do not declare local variables without an initial value.
This commit is contained in:
Kevin Ottens 2020-06-03 10:35:24 +02:00 committed by GitHub
commit 12279089f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 163 additions and 116 deletions

View file

@ -1,4 +1,5 @@
Checks: '-*,
cppcoreguidelines-init-variables,
modernize-make-shared,
modernize-redundant-void-arg,
modernize-replace-*,

View 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;

View 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) {

View 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);
@ -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;

View 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)

View 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) {

View 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;

View 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));

View 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;

View 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) {

View 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)) {

View 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.";

View 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 {

View 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);

View 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);

View 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);

View 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;

View 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()) {

View 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:"),

View 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:"),

View 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);

View 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;

View 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";

View 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;

View 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);

View 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());

View 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;

View 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");

View 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);

View file

@ -23,7 +23,7 @@
static void check_csync_instruction_str(void **state)
{
const char *str;
const char *str = nullptr;
(void) state; /* unused */

View 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 */

View file

@ -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 */

View 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);

View 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);