diff --git a/src/driver/common/fortconf.c b/src/driver/common/fortconf.c index a2799802..0bb313f9 100644 --- a/src/driver/common/fortconf.c +++ b/src/driver/common/fortconf.c @@ -160,15 +160,14 @@ FORT_API BOOL fort_conf_ip_included(const PFORT_CONF conf, const BOOL ip_excluded = exclude_all ? TRUE : fort_conf_ip_included_check(fort_conf_addr_group_exclude_list_ref(addr_group), - zone_func, ctx, remote_ip, addr_group->exclude_zones, - addr_group->exclude_is_empty, isIPv6); + zone_func, ctx, remote_ip, addr_group->exclude_zones, + addr_group->exclude_is_empty, isIPv6); if (include_all) return !ip_excluded; /* Exclude All */ - const BOOL ip_included = include_all - ? TRUE - : fort_conf_ip_included_check(fort_conf_addr_group_include_list_ref(addr_group), + const BOOL ip_included = /* include_all ? TRUE : */ + fort_conf_ip_included_check(fort_conf_addr_group_include_list_ref(addr_group), zone_func, ctx, remote_ip, addr_group->include_zones, addr_group->include_is_empty, isIPv6); if (exclude_all) @@ -206,8 +205,7 @@ typedef BOOL fort_conf_app_equal_func( static FORT_APP_ENTRY fort_conf_app_find_loop(const PFORT_CONF conf, const PVOID path, UINT32 path_len, UINT32 apps_off, UINT16 apps_n, fort_conf_app_equal_func *app_equal_func) { - FORT_APP_ENTRY app_data; - app_data.flags.v = 0; + const FORT_APP_ENTRY app_data = { 0 }; if (apps_n == 0) return app_data; @@ -256,8 +254,7 @@ static int fort_conf_app_prefix_cmp(PFORT_APP_ENTRY app_entry, const PVOID path, static FORT_APP_ENTRY fort_conf_app_prefix_find( const PFORT_CONF conf, const PVOID path, UINT32 path_len) { - FORT_APP_ENTRY app_data; - app_data.flags.v = 0; + const FORT_APP_ENTRY app_data = { 0 }; const UINT16 count = conf->prefix_apps_n; if (count == 0) diff --git a/src/ui/3rdparty/sqlite/sqlitedb.cpp b/src/ui/3rdparty/sqlite/sqlitedb.cpp index 4ad145a5..3ef278e3 100644 --- a/src/ui/3rdparty/sqlite/sqlitedb.cpp +++ b/src/ui/3rdparty/sqlite/sqlitedb.cpp @@ -470,9 +470,9 @@ bool SqliteDb::createFtsTable(const FtsTable &ftsTable) " INSERT INTO %2(rowid, %4) VALUES (%5);" "END;"; - const auto contentTableName = ftsTable.contentTable; + const auto &contentTableName = ftsTable.contentTable; const auto ftsTableName = getFtsTableName(contentTableName); - const auto contentRowidName = ftsTable.contentRowid; + const auto &contentRowidName = ftsTable.contentRowid; const auto contentColumnNames = ftsTable.columns.join(','); const auto newTriggerColumnNames = makeTriggerColumnNames(contentRowidName, ftsTable.columns, "new."); diff --git a/src/ui/3rdparty/sqlite/sqlitestmt.cpp b/src/ui/3rdparty/sqlite/sqlitestmt.cpp index 264f076e..9c9d864c 100644 --- a/src/ui/3rdparty/sqlite/sqlitestmt.cpp +++ b/src/ui/3rdparty/sqlite/sqlitestmt.cpp @@ -394,7 +394,9 @@ bool SqliteStmt::columnIsNull(int column) const void SqliteStmt::doList(const SqliteStmtList &stmtList) { for (SqliteStmt *stmt : stmtList) { - stmt->step(); + const auto stepRes = stmt->step(); + Q_UNUSED(stepRes); + stmt->reset(); } } diff --git a/src/ui/control/controlworker.cpp b/src/ui/control/controlworker.cpp index 4c60b49a..2189a1e4 100644 --- a/src/ui/control/controlworker.cpp +++ b/src/ui/control/controlworker.cpp @@ -42,7 +42,7 @@ bool buildArgsData(QByteArray &buffer, const QVariantList &args, bool &compresse } compressed = (data.size() > 128); - buffer = compressed ? qCompress(data) : data; + buffer = compressed ? qCompress(std::move(data)) : data; return true; } @@ -314,15 +314,13 @@ bool ControlWorker::readRequestHeader() { const int headerSize = socket()->read((char *) &m_requestHeader, sizeof(RequestHeader)); if (headerSize != sizeof(RequestHeader)) { - qCWarning(LC) << "Bad request header:" - << "size=" << headerSize; + qCWarning(LC) << "Bad request header:" << "size=" << headerSize; return false; } if (m_requestHeader.command() == Control::CommandNone || m_requestHeader.dataSize() > dataMaxSize) { - qCWarning(LC) << "Bad request:" - << "command=" << m_requestHeader.command() + qCWarning(LC) << "Bad request:" << "command=" << m_requestHeader.command() << "size=" << m_requestHeader.dataSize(); return false; } diff --git a/src/ui/form/controls/tableview.cpp b/src/ui/form/controls/tableview.cpp index 819f1a46..e7b64f82 100644 --- a/src/ui/form/controls/tableview.cpp +++ b/src/ui/form/controls/tableview.cpp @@ -27,7 +27,7 @@ QVector TableView::selectedRows() const { QSet rowsSet; const auto indexes = selectedIndexes(); - for (const auto index : indexes) { + for (const auto &index : indexes) { rowsSet.insert(index.row()); } @@ -56,7 +56,7 @@ QString TableView::selectedText() const int prevColumn = -1; const auto indexes = sortedSelectedIndexes(); - for (const auto index : indexes) { + for (const auto &index : indexes) { const int row = index.row(); if (prevRow != row) { if (prevRow != -1) { diff --git a/src/ui/form/controls/zonesselector.cpp b/src/ui/form/controls/zonesselector.cpp index 2056dc3c..ef32ff5b 100644 --- a/src/ui/form/controls/zonesselector.cpp +++ b/src/ui/form/controls/zonesselector.cpp @@ -151,7 +151,7 @@ void ZonesSelector::createZonesMenu() const int zoneCount = qMin(zoneListModel->rowCount(), maxZoneCount()); for (int row = 0; row < zoneCount; ++row) { - const auto zoneRow = zoneListModel->zoneRowAt(row); + const auto &zoneRow = zoneListModel->zoneRowAt(row); auto cb = new QCheckBox(zoneRow.zoneName, m_menuZones); cb->setTristate(isTristate()); diff --git a/src/ui/form/home/pages/homepage.cpp b/src/ui/form/home/pages/homepage.cpp index b1d6a3ec..5f446b0e 100644 --- a/src/ui/form/home/pages/homepage.cpp +++ b/src/ui/form/home/pages/homepage.cpp @@ -33,7 +33,7 @@ void HomePage::onRetranslateUi() void HomePage::retranslateDriverMessage() { - const auto text = driverManager()->isDeviceError() + const auto &text = driverManager()->isDeviceError() ? driverManager()->errorMessage() : (driverManager()->isDeviceOpened() ? tr("Installed") : tr("Not Installed")); diff --git a/src/ui/form/prog/programswindow.cpp b/src/ui/form/prog/programswindow.cpp index 3b7c88f1..d111bedd 100644 --- a/src/ui/form/prog/programswindow.cpp +++ b/src/ui/form/prog/programswindow.cpp @@ -524,7 +524,7 @@ QVector ProgramsWindow::selectedAppIdList() const const auto rows = m_appListView->selectedRows(); for (int row : rows) { - const auto appRow = appListModel()->appRowAt(row); + const auto &appRow = appListModel()->appRowAt(row); list.append(appRow.appId); } diff --git a/src/ui/form/rule/ruleswindow.cpp b/src/ui/form/rule/ruleswindow.cpp index 6dbf9c9b..e384c1be 100644 --- a/src/ui/form/rule/ruleswindow.cpp +++ b/src/ui/form/rule/ruleswindow.cpp @@ -310,7 +310,7 @@ void RulesWindow::editSelectedRule() if (RuleListModel::isIndexRoot(ruleIndex)) return; - const RuleRow ruleRow = ruleListModel()->ruleRowAt(ruleIndex); + const auto &ruleRow = ruleListModel()->ruleRowAt(ruleIndex); openRuleEditForm(ruleRow); } @@ -332,7 +332,7 @@ void RulesWindow::deleteSelectedRule() if (RuleListModel::isIndexRoot(ruleIndex)) return; - const auto ruleRow = ruleListModel()->ruleRowAt(ruleIndex); + const auto &ruleRow = ruleListModel()->ruleRowAt(ruleIndex); if (ruleRow.isNull()) return; diff --git a/src/ui/form/stat/pages/connectionspage.cpp b/src/ui/form/stat/pages/connectionspage.cpp index a7de50b4..16fa4a83 100644 --- a/src/ui/form/stat/pages/connectionspage.cpp +++ b/src/ui/form/stat/pages/connectionspage.cpp @@ -285,7 +285,7 @@ void ConnectionsPage::updateShowHostNames() void ConnectionsPage::deleteConn(int row) { - const auto connRow = connBlockListModel()->connRowAt(row); + const auto &connRow = connBlockListModel()->connRowAt(row); if (connRow.isNull()) return; @@ -299,6 +299,6 @@ int ConnectionsPage::connListCurrentIndex() const QString ConnectionsPage::connListCurrentPath() const { - const auto connRow = connBlockListModel()->connRowAt(connListCurrentIndex()); + const auto &connRow = connBlockListModel()->connRowAt(connListCurrentIndex()); return connRow.isNull() ? QString() : connRow.appPath; } diff --git a/src/ui/form/svc/serviceswindow.cpp b/src/ui/form/svc/serviceswindow.cpp index 574c594d..49039766 100644 --- a/src/ui/form/svc/serviceswindow.cpp +++ b/src/ui/form/svc/serviceswindow.cpp @@ -165,7 +165,7 @@ QLayout *ServicesWindow::setupHeader() if (serviceIndex < 0) return; - const auto serviceInfo = serviceListModel()->serviceInfoAt(serviceIndex); + const auto &serviceInfo = serviceListModel()->serviceInfoAt(serviceIndex); serviceInfoManager()->trackService(serviceInfo.serviceName); updateServiceListModel(); @@ -177,7 +177,7 @@ QLayout *ServicesWindow::setupHeader() if (serviceIndex < 0) return; - const auto serviceInfo = serviceListModel()->serviceInfoAt(serviceIndex); + const auto &serviceInfo = serviceListModel()->serviceInfoAt(serviceIndex); serviceInfoManager()->revertService(serviceInfo.serviceName); updateServiceListModel(); @@ -187,7 +187,7 @@ QLayout *ServicesWindow::setupHeader() if (serviceIndex < 0) return; - const auto serviceInfo = serviceListModel()->serviceInfoAt(serviceIndex); + const auto &serviceInfo = serviceListModel()->serviceInfoAt(serviceIndex); const QString appPath = QStringLiteral(R"(\SvcHost\)") + serviceInfo.serviceName; @@ -247,7 +247,8 @@ void ServicesWindow::setupTableServicesChanged() const auto refreshTableServicesChanged = [&] { const int serviceIndex = serviceListCurrentIndex(); const bool serviceSelected = (serviceIndex >= 0); - const auto serviceInfo = serviceListModel()->serviceInfoAt(serviceIndex); + const auto &serviceInfo = serviceListModel()->serviceInfoAt(serviceIndex); + m_actTrack->setEnabled(serviceSelected && !serviceInfo.isTracked()); m_actRevert->setEnabled(serviceSelected && serviceInfo.isTracked()); m_actAddProgram->setEnabled(serviceSelected); diff --git a/src/ui/form/zone/zoneswindow.cpp b/src/ui/form/zone/zoneswindow.cpp index fa14f704..23c14b23 100644 --- a/src/ui/form/zone/zoneswindow.cpp +++ b/src/ui/form/zone/zoneswindow.cpp @@ -282,7 +282,7 @@ void ZonesWindow::editSelectedZone() if (zoneIndex < 0) return; - const ZoneRow zoneRow = zoneListModel()->zoneRowAt(zoneIndex); + const auto &zoneRow = zoneListModel()->zoneRowAt(zoneIndex); openZoneEditForm(zoneRow); } @@ -300,7 +300,7 @@ void ZonesWindow::openZoneEditForm(const ZoneRow &zoneRow) void ZonesWindow::deleteZone(int row) { - const auto zoneRow = zoneListModel()->zoneRowAt(row); + const auto &zoneRow = zoneListModel()->zoneRowAt(row); if (zoneRow.isNull()) return; diff --git a/src/ui/manager/logger.cpp b/src/ui/manager/logger.cpp index e3a9703f..aac3571b 100644 --- a/src/ui/manager/logger.cpp +++ b/src/ui/manager/logger.cpp @@ -175,7 +175,7 @@ bool Logger::openLastFile() if (fileNames.isEmpty()) return false; - const auto fileName = fileNames.first(); + const auto &fileName = fileNames.first(); if (!openFile(fileName)) return false; diff --git a/src/ui/manager/serviceinfomanager.cpp b/src/ui/manager/serviceinfomanager.cpp index 465abfe9..6b7d7ab3 100644 --- a/src/ui/manager/serviceinfomanager.cpp +++ b/src/ui/manager/serviceinfomanager.cpp @@ -87,7 +87,7 @@ void fillServiceInfoList(QVector &infoList, const RegKey &servicesR info.serviceType = ServiceInfo::Type(service->ServiceStatusProcess.dwServiceType); info.trackFlags = trackFlags; info.processId = service->ServiceStatusProcess.dwProcessId; - info.serviceName = serviceName; + info.serviceName = std::move(serviceName); if (displayName) { info.displayName = QString::fromUtf16((const char16_t *) service->lpDisplayName); diff --git a/src/ui/model/applistmodel.cpp b/src/ui/model/applistmodel.cpp index de7472b3..49411d55 100644 --- a/src/ui/model/applistmodel.cpp +++ b/src/ui/model/applistmodel.cpp @@ -328,7 +328,7 @@ QVariant AppListModel::dataDisplay(const QModelIndex &index, int role) const const int row = index.row(); const int column = index.column(); - const auto appRow = appRowAt(row); + const auto &appRow = appRowAt(row); if (appRow.isNull()) return QVariant(); @@ -340,7 +340,7 @@ QVariant AppListModel::dataDecoration(const QModelIndex &index) const const int row = index.row(); const int column = index.column(); - const auto appRow = appRowAt(row); + const auto &appRow = appRowAt(row); if (appRow.isNull()) return QVariant(); @@ -363,7 +363,7 @@ QVariant AppListModel::dataForeground(const QModelIndex &index) const const int column = index.column(); const int row = index.row(); - const auto appRow = appRowAt(row); + const auto &appRow = appRowAt(row); switch (column) { case 3: diff --git a/src/ui/model/appstatmodel.cpp b/src/ui/model/appstatmodel.cpp index 9b2e63a2..a229bb9b 100644 --- a/src/ui/model/appstatmodel.cpp +++ b/src/ui/model/appstatmodel.cpp @@ -134,7 +134,7 @@ QVariant AppStatModel::dataDisplay(const QModelIndex &index) const if (row == 0) return tr("All"); - const auto appPath = list().at(row); + const auto &appPath = list().at(row); return appInfoCache()->appName(appPath); } @@ -145,6 +145,6 @@ QVariant AppStatModel::dataDecoration(const QModelIndex &index) const return IconCache::icon(":/icons/computer-96.png"); } - const auto appPath = list().at(row); + const auto &appPath = list().at(row); return appInfoCache()->appIcon(appPath); } diff --git a/src/ui/model/connblocklistmodel.cpp b/src/ui/model/connblocklistmodel.cpp index b4cc1726..c78f14dd 100644 --- a/src/ui/model/connblocklistmodel.cpp +++ b/src/ui/model/connblocklistmodel.cpp @@ -137,7 +137,7 @@ QVariant ConnBlockListModel::dataDisplay(const QModelIndex &index, int role) con const int row = index.row(); const int column = index.column(); - const auto connRow = connRowAt(row); + const auto &connRow = connRowAt(row); switch (column) { case 0: @@ -176,7 +176,7 @@ QVariant ConnBlockListModel::dataDecoration(const QModelIndex &index) const if (column == 0 || column == 5) { const int row = index.row(); - const auto connRow = connRowAt(row); + const auto &connRow = connRowAt(row); switch (column) { case 0: diff --git a/src/ui/model/rulelistmodel.cpp b/src/ui/model/rulelistmodel.cpp index 549fdceb..fe8721f5 100644 --- a/src/ui/model/rulelistmodel.cpp +++ b/src/ui/model/rulelistmodel.cpp @@ -223,7 +223,7 @@ QVariant RuleListModel::headerDataDisplay(int section) const QVariant RuleListModel::dataDisplay(const QModelIndex &index, int role) const { - const auto ruleRow = ruleRowAt(index); + const auto &ruleRow = ruleRowAt(index); switch (index.column()) { case 0: @@ -237,7 +237,7 @@ QVariant RuleListModel::dataDisplay(const QModelIndex &index, int role) const QVariant RuleListModel::dataDecoration(const QModelIndex &index) const { - const auto ruleRow = ruleRowAt(index); + const auto &ruleRow = ruleRowAt(index); if (ruleRow.isNull()) return QVariant(); @@ -252,7 +252,7 @@ QVariant RuleListModel::dataDecoration(const QModelIndex &index) const QVariant RuleListModel::dataCheckState(const QModelIndex &index) const { if (index.column() == 0) { - const auto ruleRow = ruleRowAt(index); + const auto &ruleRow = ruleRowAt(index); return ruleRow.enabled ? Qt::Checked : Qt::Unchecked; } @@ -268,7 +268,7 @@ bool RuleListModel::setData(const QModelIndex &index, const QVariant & /*value*/ switch (role) { case Qt::CheckStateRole: - const auto ruleRow = ruleRowAt(index); + const auto &ruleRow = ruleRowAt(index); return confRuleManager()->updateRuleEnabled(ruleRow.ruleId, !ruleRow.enabled); } diff --git a/src/ui/model/servicelistmodel.cpp b/src/ui/model/servicelistmodel.cpp index 5171815a..3144ff3d 100644 --- a/src/ui/model/servicelistmodel.cpp +++ b/src/ui/model/servicelistmodel.cpp @@ -79,7 +79,7 @@ QVariant ServiceListModel::dataDisplay(const QModelIndex &index) const const int row = index.row(); const int column = index.column(); - const auto info = serviceInfoAt(row); + const auto &info = serviceInfoAt(row); switch (column) { case 0: @@ -105,7 +105,7 @@ QVariant ServiceListModel::dataDecoration(const QModelIndex &index) const if (column == 0) { const int row = index.row(); - const auto info = serviceInfoAt(row); + const auto &info = serviceInfoAt(row); if (info.isTracked()) return IconCache::icon(":/icons/widgets.png"); diff --git a/src/ui/model/zonelistmodel.cpp b/src/ui/model/zonelistmodel.cpp index 51ebd216..b29aa4bf 100644 --- a/src/ui/model/zonelistmodel.cpp +++ b/src/ui/model/zonelistmodel.cpp @@ -104,7 +104,7 @@ QVariant ZoneListModel::dataDisplay(const QModelIndex &index) const const int row = index.row(); const int column = index.column(); - const auto zoneRow = zoneRowAt(row); + const auto &zoneRow = zoneRowAt(row); switch (column) { case 0: @@ -127,7 +127,7 @@ QVariant ZoneListModel::dataDisplay(const QModelIndex &index) const QVariant ZoneListModel::dataCheckState(const QModelIndex &index) const { if (index.column() == 0) { - const auto zoneRow = zoneRowAt(index.row()); + const auto &zoneRow = zoneRowAt(index.row()); return zoneRow.enabled ? Qt::Checked : Qt::Unchecked; } @@ -143,7 +143,7 @@ bool ZoneListModel::setData(const QModelIndex &index, const QVariant &value, int switch (role) { case Qt::CheckStateRole: - const auto zoneRow = zoneRowAt(index.row()); + const auto &zoneRow = zoneRowAt(index.row()); return confZoneManager()->updateZoneEnabled(zoneRow.zoneId, !zoneRow.enabled); } diff --git a/src/ui/rpc/rpcmanager.cpp b/src/ui/rpc/rpcmanager.cpp index 5c826e0b..7180e6cf 100644 --- a/src/ui/rpc/rpcmanager.cpp +++ b/src/ui/rpc/rpcmanager.cpp @@ -166,7 +166,7 @@ bool RpcManager::doOnServer(Control::Command cmd, const QVariantList &args, QVar void RpcManager::invokeOnClients(Control::Command cmd, const QVariantList &args) { - const auto clients = IoC()->clients(); + const auto &clients = IoC()->clients(); if (clients.isEmpty()) return; diff --git a/src/ui/task/taskinfozonedownloader.cpp b/src/ui/task/taskinfozonedownloader.cpp index 6c74a9e0..eb890581 100644 --- a/src/ui/task/taskinfozonedownloader.cpp +++ b/src/ui/task/taskinfozonedownloader.cpp @@ -93,10 +93,10 @@ void TaskInfoZoneDownloader::setupNextTaskWorker() void TaskInfoZoneDownloader::setupTaskWorkerByZone(TaskZoneDownloader *worker) { - const auto zoneRow = zoneListModel()->zoneRowAt(m_zoneIndex); - const auto zoneSource = - ZoneSourceWrapper(zoneListModel()->zoneSourceByCode(zoneRow.sourceCode)); - const auto zoneType = ZoneTypeWrapper(zoneListModel()->zoneTypeByCode(zoneSource.zoneType())); + const auto &zoneRow = zoneListModel()->zoneRowAt(m_zoneIndex); + + const ZoneSourceWrapper zoneSource(zoneListModel()->zoneSourceByCode(zoneRow.sourceCode)); + const ZoneTypeWrapper zoneType(zoneListModel()->zoneTypeByCode(zoneSource.zoneType())); worker->setZoneEnabled(zoneRow.enabled); worker->setSort(zoneType.sort()); @@ -173,7 +173,7 @@ void TaskInfoZoneDownloader::addSubResult(TaskZoneDownloader *worker, bool succe return; } - const auto zoneData = worker->zoneData(); + const auto &zoneData = worker->zoneData(); const int size = zoneData.size(); if (size == 0) diff --git a/src/ui/util/service/servicelistmonitor.cpp b/src/ui/util/service/servicelistmonitor.cpp index c54c48c7..808f072c 100644 --- a/src/ui/util/service/servicelistmonitor.cpp +++ b/src/ui/util/service/servicelistmonitor.cpp @@ -54,7 +54,8 @@ void CALLBACK managerNotifyCallback(PVOID param) } QMetaObject::invokeMethod( - monitor, [=] { monitor->onManagerNotify(createdServiceNames); }, Qt::QueuedConnection); + monitor, [=] { monitor->onManagerNotify(std::move(createdServiceNames)); }, + Qt::QueuedConnection); } } diff --git a/src/ui/util/startuputil.cpp b/src/ui/util/startuputil.cpp index 4e153b32..8a296343 100644 --- a/src/ui/util/startuputil.cpp +++ b/src/ui/util/startuputil.cpp @@ -233,11 +233,11 @@ void StartupUtil::setExplorerIntegrated(bool integrate) if (integrate) { const QString wrappedPath = wrappedAppFilePath(); - RegKey reg(regShell, APP_NAME, RegKey::DefaultCreate); + RegKey reg(std::move(regShell), APP_NAME, RegKey::DefaultCreate); reg.setValue("icon", wrappedPath); reg.setValue("MUIVerb", APP_NAME + QLatin1String(" ...")); - RegKey regCommand(reg, "command", RegKey::DefaultCreate); + RegKey regCommand(std::move(reg), "command", RegKey::DefaultCreate); regCommand.setDefaultValue(wrappedPath + " -c prog add \"%1\""); } else { regShell.removeRecursively(APP_NAME);