mirror of
https://github.com/tnodir/fort
synced 2024-11-15 01:25:52 +00:00
UI: Fix PVS-Studio warnings
This commit is contained in:
parent
080c47ce20
commit
1de63c0792
@ -68,6 +68,6 @@
|
||||
|
||||
#define FORT_ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
#define FORT_ALIGN_SIZE(size, align) ((((size) + (align - 1)) & ~(align - 1)))
|
||||
#define FORT_ALIGN_SIZE(size, align) ((((size) + ((align) - 1)) & ~((align) - 1)))
|
||||
|
||||
#endif // COMMON_H
|
||||
|
@ -170,7 +170,7 @@ typedef struct fort_conf_rule_flag
|
||||
} FORT_CONF_RULE_FLAG, *PFORT_CONF_RULE_FLAG;
|
||||
|
||||
#define FORT_CONF_RULES_DATA_OFF offsetof(FORT_CONF_RULES, data)
|
||||
#define FORT_CONF_RULES_OFFSETS_SIZE(max_rule_id) ((max_rule_id + 1) * sizeof(UINT32))
|
||||
#define FORT_CONF_RULES_OFFSETS_SIZE(max_rule_id) (((max_rule_id) + 1) * sizeof(UINT32))
|
||||
#define FORT_CONF_RULE_SIZE(rule) \
|
||||
(sizeof(FORT_CONF_RULE) + ((rule)->has_zones ? sizeof(FORT_CONF_RULE_ZONES) : 0) \
|
||||
+ (rule)->set_count * sizeof(UINT16))
|
||||
|
@ -178,7 +178,7 @@ DEFINE_GUID(FORT_GUID_EMPTY, 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,
|
||||
#define FORT_CTL_CODE(i, a) CTL_CODE(FORT_DEVICE_TYPE, FORT_IOCTL_BASE + (i), METHOD_BUFFERED, (a))
|
||||
|
||||
/* Macro to extract function index out of the device io control code */
|
||||
#define FORT_CTL_INDEX_FROM_CODE(ctrlCode) ((DWORD) ((ctrlCode >> 2) & 0xFF))
|
||||
#define FORT_CTL_INDEX_FROM_CODE(ctrlCode) ((DWORD) (((ctrlCode) >> 2) & 0xFF))
|
||||
|
||||
#define FORT_IOCTL_INDEX_VALIDATE 0
|
||||
#define FORT_IOCTL_INDEX_SETSERVICES 1
|
||||
|
@ -25,7 +25,7 @@ typedef struct
|
||||
const PUCHAR lpData;
|
||||
DWORD dwSize;
|
||||
DWORD imageSize;
|
||||
} FORT_MODULE_IMAGE;
|
||||
} FORT_MODULE_IMAGE, *PFORT_MODULE_IMAGE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -33,7 +33,7 @@ typedef struct
|
||||
PIMAGE_IMPORT_DESCRIPTOR importDesc;
|
||||
LPCSTR libName;
|
||||
PLOADEDMODULE libModule;
|
||||
} FORT_MODULE_IMAGE_LIB;
|
||||
} FORT_MODULE_IMAGE_LIB, *PFORT_MODULE_IMAGE_LIB;
|
||||
|
||||
static VOID ZeroDataSectionTable(
|
||||
PUCHAR pImage, const PIMAGE_NT_HEADERS pNtHeaders, PIMAGE_SECTION_HEADER section)
|
||||
@ -54,26 +54,26 @@ static VOID ZeroDataSectionTable(
|
||||
#endif
|
||||
}
|
||||
|
||||
static NTSTATUS CopySectionTable(PUCHAR pImage, const FORT_MODULE_IMAGE mi)
|
||||
static NTSTATUS CopySectionTable(PUCHAR pImage, const PFORT_MODULE_IMAGE mi)
|
||||
{
|
||||
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(mi.pNtHeaders);
|
||||
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(mi->pNtHeaders);
|
||||
|
||||
const int numberOfSections = mi.pNtHeaders->FileHeader.NumberOfSections;
|
||||
const int numberOfSections = mi->pNtHeaders->FileHeader.NumberOfSections;
|
||||
|
||||
for (int i = 0; i < numberOfSections; ++i, ++section) {
|
||||
const DWORD sectionSize = section->SizeOfRawData;
|
||||
if (sectionSize == 0) {
|
||||
ZeroDataSectionTable(pImage, mi.pNtHeaders, section);
|
||||
ZeroDataSectionTable(pImage, mi->pNtHeaders, section);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (section->VirtualAddress + sectionSize > mi.imageSize
|
||||
|| section->PointerToRawData + sectionSize > mi.dwSize)
|
||||
if (section->VirtualAddress + sectionSize > mi->imageSize
|
||||
|| section->PointerToRawData + sectionSize > mi->dwSize)
|
||||
return STATUS_INVALID_IMAGE_FORMAT;
|
||||
|
||||
/* Always use position from file to support alignments smaller than page size. */
|
||||
PUCHAR dest = pImage + section->VirtualAddress;
|
||||
RtlCopyMemory(dest, mi.lpData + section->PointerToRawData, sectionSize);
|
||||
RtlCopyMemory(dest, mi->lpData + section->PointerToRawData, sectionSize);
|
||||
|
||||
/* NOTE: On 64bit systems we truncate to 32bit here but expand
|
||||
* again later when "PhysicalAddress" is used.
|
||||
@ -160,18 +160,19 @@ static NTSTATUS PerformBaseRelocation(
|
||||
}
|
||||
|
||||
/* Build the import address table: Library functions. */
|
||||
static NTSTATUS BuildImportTableLibrary(PFORT_MODULE_IMP moduleImp, const FORT_MODULE_IMAGE_LIB mil)
|
||||
static NTSTATUS BuildImportTableLibrary(
|
||||
PFORT_MODULE_IMP moduleImp, const PFORT_MODULE_IMAGE_LIB mil)
|
||||
{
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
|
||||
ModuleGetProcAddressFallbackProc moduleGetProcAddressFallback =
|
||||
moduleImp->moduleGetProcAddressFallback;
|
||||
|
||||
const DWORD originalFirstThunk = (mil.importDesc->OriginalFirstThunk != 0)
|
||||
? mil.importDesc->OriginalFirstThunk
|
||||
: mil.importDesc->FirstThunk;
|
||||
uintptr_t *thunkRef = (uintptr_t *) (mil.codeBase + originalFirstThunk);
|
||||
FARPROC *funcRef = (FARPROC *) (mil.codeBase + mil.importDesc->FirstThunk);
|
||||
const DWORD originalFirstThunk = (mil->importDesc->OriginalFirstThunk != 0)
|
||||
? mil->importDesc->OriginalFirstThunk
|
||||
: mil->importDesc->FirstThunk;
|
||||
uintptr_t *thunkRef = (uintptr_t *) (mil->codeBase + originalFirstThunk);
|
||||
FARPROC *funcRef = (FARPROC *) (mil->codeBase + mil->importDesc->FirstThunk);
|
||||
|
||||
for (; *thunkRef; ++thunkRef, ++funcRef) {
|
||||
LPCSTR funcName;
|
||||
@ -179,17 +180,17 @@ static NTSTATUS BuildImportTableLibrary(PFORT_MODULE_IMP moduleImp, const FORT_M
|
||||
funcName = (LPCSTR) IMAGE_ORDINAL(*thunkRef);
|
||||
} else {
|
||||
const PIMAGE_IMPORT_BY_NAME thunkData =
|
||||
(PIMAGE_IMPORT_BY_NAME) (mil.codeBase + (*thunkRef));
|
||||
(PIMAGE_IMPORT_BY_NAME) (mil->codeBase + (*thunkRef));
|
||||
funcName = (LPCSTR) &thunkData->Name;
|
||||
}
|
||||
|
||||
*funcRef = moduleGetProcAddressFallback(moduleImp, mil.libModule, funcName);
|
||||
*funcRef = moduleGetProcAddressFallback(moduleImp, mil->libModule, funcName);
|
||||
if (*funcRef == NULL) {
|
||||
LOG("Loader Module: Error: Procedure Not Found: %s: %s\n", mil.libName, funcName);
|
||||
LOG("Loader Module: Error: Procedure Not Found: %s: %s\n", mil->libName, funcName);
|
||||
status = STATUS_PROCEDURE_NOT_FOUND;
|
||||
} else {
|
||||
#ifdef FORT_DEBUG
|
||||
LOG("Loader Module: Import: %s: %s: %p\n", mil.libName, funcName, *funcRef);
|
||||
LOG("Loader Module: Import: %s: %s: %p\n", mil->libName, funcName, *funcRef);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -229,7 +230,7 @@ static NTSTATUS BuildImportTableEntries(
|
||||
moduleLib.libName = libName;
|
||||
moduleLib.libModule = &libModule;
|
||||
|
||||
status = BuildImportTableLibrary(moduleImp, moduleLib);
|
||||
status = BuildImportTableLibrary(moduleImp, &moduleLib);
|
||||
if (!NT_SUCCESS(status)) {
|
||||
LOG("Loader Module: Library Import Error: %s\n", libName);
|
||||
break;
|
||||
@ -240,17 +241,17 @@ static NTSTATUS BuildImportTableEntries(
|
||||
}
|
||||
|
||||
/* Build the import address table. */
|
||||
static NTSTATUS BuildImportTable(const FORT_MODULE_IMAGE mi)
|
||||
static NTSTATUS BuildImportTable(const PFORT_MODULE_IMAGE mi)
|
||||
{
|
||||
NTSTATUS status;
|
||||
|
||||
PIMAGE_DATA_DIRECTORY directory =
|
||||
&(mi.pNtHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]);
|
||||
&(mi->pNtHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]);
|
||||
if (directory->Size == 0)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
DriverImportsSetupProc driverImportsSetup =
|
||||
(DriverImportsSetupProc) ModuleGetProcAddress(mi.pModule, "DriverImportsSetup");
|
||||
(DriverImportsSetupProc) ModuleGetProcAddress(mi->pModule, "DriverImportsSetup");
|
||||
if (driverImportsSetup == NULL)
|
||||
return STATUS_DRIVER_ORDINAL_NOT_FOUND;
|
||||
|
||||
@ -265,14 +266,14 @@ static NTSTATUS BuildImportTable(const FORT_MODULE_IMAGE mi)
|
||||
|
||||
driverImportsSetup(&moduleImp);
|
||||
|
||||
status = moduleImp.buildImportTableEntriesBegin(&moduleImp, mi.pModule, mi.pNtHeaders);
|
||||
status = moduleImp.buildImportTableEntriesBegin(&moduleImp, mi->pModule, mi->pNtHeaders);
|
||||
if (!NT_SUCCESS(status))
|
||||
return status;
|
||||
|
||||
if (status == STATUS_ALREADY_COMPLETE) {
|
||||
status = STATUS_SUCCESS;
|
||||
} else {
|
||||
status = BuildImportTableEntries(&moduleImp, mi.pModule->codeBase, directory);
|
||||
status = BuildImportTableEntries(&moduleImp, mi->pModule->codeBase, directory);
|
||||
}
|
||||
|
||||
moduleImp.buildImportTableEntriesEnd(&moduleImp, status);
|
||||
@ -347,65 +348,65 @@ inline static BOOL CheckPEHeaderOptionalValid(const PIMAGE_NT_HEADERS pNtHeaders
|
||||
return CheckPEHeaderSections(pNtHeaders);
|
||||
}
|
||||
|
||||
static BOOL IsPEHeaderValid(const FORT_MODULE_IMAGE mi)
|
||||
static BOOL IsPEHeaderValid(const PFORT_MODULE_IMAGE mi)
|
||||
{
|
||||
const PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER) mi.lpData;
|
||||
const PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER) mi->lpData;
|
||||
|
||||
/* Check DOS header for valid signature */
|
||||
if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE)
|
||||
return FALSE;
|
||||
|
||||
/* Make sure size is at least size of headers */
|
||||
if (mi.dwSize < (sizeof(IMAGE_DOS_HEADER) + sizeof(IMAGE_OPTIONAL_HEADER)))
|
||||
if (mi->dwSize < (sizeof(IMAGE_DOS_HEADER) + sizeof(IMAGE_OPTIONAL_HEADER)))
|
||||
return FALSE;
|
||||
|
||||
if (mi.dwSize < (pDosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS)))
|
||||
if (mi->dwSize < (pDosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS)))
|
||||
return FALSE;
|
||||
|
||||
/* Check for optional headers */
|
||||
const PIMAGE_NT_HEADERS pNtHeaders =
|
||||
(PIMAGE_NT_HEADERS) & ((PUCHAR) mi.lpData)[pDosHeader->e_lfanew];
|
||||
(PIMAGE_NT_HEADERS) & ((PUCHAR) mi->lpData)[pDosHeader->e_lfanew];
|
||||
|
||||
return CheckPEHeaderOptionalValid(pNtHeaders, mi.dwSize);
|
||||
return CheckPEHeaderOptionalValid(pNtHeaders, mi->dwSize);
|
||||
}
|
||||
|
||||
static NTSTATUS InitializeModuleImage(const FORT_MODULE_IMAGE mi)
|
||||
static NTSTATUS InitializeModuleImage(const PFORT_MODULE_IMAGE mi)
|
||||
{
|
||||
NTSTATUS status;
|
||||
|
||||
#ifdef FORT_DEBUG
|
||||
LOG("Loader Module: Init Image: SizeOfHeaders=%d EntryPoint=%d ImageBase=%x\n",
|
||||
mi.pNtHeaders->OptionalHeader.SizeOfHeaders,
|
||||
mi.pNtHeaders->OptionalHeader.AddressOfEntryPoint,
|
||||
mi.pNtHeaders->OptionalHeader.ImageBase);
|
||||
mi->pNtHeaders->OptionalHeader.SizeOfHeaders,
|
||||
mi->pNtHeaders->OptionalHeader.AddressOfEntryPoint,
|
||||
mi->pNtHeaders->OptionalHeader.ImageBase);
|
||||
#endif
|
||||
|
||||
PUCHAR pImage = mi.pModule->codeBase;
|
||||
PUCHAR pImage = mi->pModule->codeBase;
|
||||
|
||||
/* Copy PE header */
|
||||
RtlCopyMemory(pImage, mi.lpData, mi.pNtHeaders->OptionalHeader.SizeOfHeaders);
|
||||
RtlCopyMemory(pImage, mi->lpData, mi->pNtHeaders->OptionalHeader.SizeOfHeaders);
|
||||
|
||||
/* Update position of the image base */
|
||||
PIMAGE_NT_HEADERS pNtHeaders = GetModuleNtHeaders(pImage);
|
||||
pNtHeaders->OptionalHeader.ImageBase = (uintptr_t) pImage;
|
||||
|
||||
/* Copy section table */
|
||||
FORT_MODULE_IMAGE newModule = mi;
|
||||
FORT_MODULE_IMAGE newModule = *mi;
|
||||
newModule.pNtHeaders = pNtHeaders;
|
||||
|
||||
status = CopySectionTable(pImage, newModule);
|
||||
status = CopySectionTable(pImage, &newModule);
|
||||
if (!NT_SUCCESS(status))
|
||||
return status;
|
||||
|
||||
/* Adjust base address of imported data */
|
||||
const ptrdiff_t locationDelta = pImage - (PUCHAR) mi.pNtHeaders->OptionalHeader.ImageBase;
|
||||
const ptrdiff_t locationDelta = pImage - (PUCHAR) mi->pNtHeaders->OptionalHeader.ImageBase;
|
||||
|
||||
if (locationDelta != 0) {
|
||||
PerformBaseRelocation(pImage, pNtHeaders, locationDelta);
|
||||
}
|
||||
|
||||
/* Adjust function table of imports */
|
||||
status = BuildImportTable(newModule);
|
||||
status = BuildImportTable(&newModule);
|
||||
if (!NT_SUCCESS(status))
|
||||
return status;
|
||||
|
||||
@ -423,7 +424,7 @@ FORT_API NTSTATUS LoadModuleFromMemory(PLOADEDMODULE pModule, const PUCHAR lpDat
|
||||
};
|
||||
|
||||
/* Check header */
|
||||
if (!IsPEHeaderValid(module))
|
||||
if (!IsPEHeaderValid(&module))
|
||||
return STATUS_INVALID_IMAGE_FORMAT;
|
||||
|
||||
const PIMAGE_NT_HEADERS pNtHeaders = GetModuleNtHeaders(lpData);
|
||||
@ -447,7 +448,7 @@ FORT_API NTSTATUS LoadModuleFromMemory(PLOADEDMODULE pModule, const PUCHAR lpDat
|
||||
module.pNtHeaders = pNtHeaders;
|
||||
module.imageSize = imageSize;
|
||||
|
||||
status = InitializeModuleImage(module);
|
||||
status = InitializeModuleImage(&module);
|
||||
|
||||
if (!NT_SUCCESS(status)) {
|
||||
pModule->codeBase = NULL;
|
||||
|
2
src/ui/3rdparty/sqlite/sqlitedb.h
vendored
2
src/ui/3rdparty/sqlite/sqlitedb.h
vendored
@ -45,7 +45,7 @@ public:
|
||||
|
||||
struct MigrateOptions
|
||||
{
|
||||
const char *sqlDir;
|
||||
const char *sqlDir = nullptr;
|
||||
const char *sqlPragmas = nullptr;
|
||||
|
||||
int version = 0;
|
||||
|
@ -114,7 +114,7 @@ const char *const sqlUpdateApp = "UPDATE app"
|
||||
|
||||
const char *const sqlUpdateAppName = "UPDATE app SET name = ?2 WHERE app_id = ?1;";
|
||||
|
||||
const char *const sqlDeleteApp = "DELETE FROM app WHERE app_id = ?1 RETURNING path, is_wildcard;";
|
||||
const char *const sqlDeleteApp = "DELETE FROM app WHERE app_id = ?1 RETURNING is_wildcard, path;";
|
||||
|
||||
const char *const sqlInsertAppAlert = "INSERT INTO app_alert(app_id) VALUES(?1);";
|
||||
|
||||
@ -429,11 +429,11 @@ bool ConfAppManager::deleteApp(qint64 appId, bool &isWildcard)
|
||||
commitTransaction(ok);
|
||||
|
||||
if (ok) {
|
||||
const QString appPath = resList.at(0).toString();
|
||||
|
||||
if (resList.at(1).toBool()) {
|
||||
if (resList.at(0).toBool()) {
|
||||
isWildcard = true;
|
||||
} else {
|
||||
const QString appPath = resList.at(0).toString();
|
||||
|
||||
updateDriverDeleteApp(appPath);
|
||||
}
|
||||
|
||||
|
@ -555,7 +555,7 @@ void ConfManager::updateConfPeriods()
|
||||
if (!applyConfPeriods(/*onlyFlags=*/false))
|
||||
return;
|
||||
|
||||
if (activeGroupBits != conf()->activeGroupBits()) {
|
||||
if (conf() && activeGroupBits != conf()->activeGroupBits()) {
|
||||
emit confPeriodsChanged();
|
||||
}
|
||||
}
|
||||
|
@ -212,21 +212,21 @@ bool ConfRuleManager::addOrUpdateRule(Rule &rule)
|
||||
.getFreeId(/*maxId=*/ConfUtil::ruleMaxCount() - 1);
|
||||
}
|
||||
|
||||
const QVariantList vars = {
|
||||
DbVar::nullable(rule.ruleId),
|
||||
rule.enabled,
|
||||
rule.blocked,
|
||||
rule.exclusive,
|
||||
rule.ruleName,
|
||||
rule.notes,
|
||||
rule.ruleText,
|
||||
rule.ruleType,
|
||||
rule.acceptZones,
|
||||
rule.rejectZones,
|
||||
DateUtil::now(),
|
||||
};
|
||||
|
||||
if (ok) {
|
||||
const QVariantList vars = {
|
||||
DbVar::nullable(rule.ruleId),
|
||||
rule.enabled,
|
||||
rule.blocked,
|
||||
rule.exclusive,
|
||||
rule.ruleName,
|
||||
rule.notes,
|
||||
rule.ruleText,
|
||||
rule.ruleType,
|
||||
rule.acceptZones,
|
||||
rule.rejectZones,
|
||||
DateUtil::now(),
|
||||
};
|
||||
|
||||
DbQuery(sqliteDb(), &ok).sql(isNew ? sqlInsertRule : sqlUpdateRule).vars(vars).executeOk();
|
||||
|
||||
saveRuleSet(rule);
|
||||
|
@ -111,18 +111,18 @@ bool ConfZoneManager::addOrUpdateZone(Zone &zone)
|
||||
updateDriverZoneFlag(zone.zoneId, zone.enabled);
|
||||
}
|
||||
|
||||
const QVariantList vars = {
|
||||
zone.zoneId,
|
||||
zone.zoneName,
|
||||
zone.enabled,
|
||||
zone.customUrl,
|
||||
zone.sourceCode,
|
||||
zone.url,
|
||||
zone.formData,
|
||||
zone.textInline,
|
||||
};
|
||||
|
||||
if (ok) {
|
||||
const QVariantList vars = {
|
||||
zone.zoneId,
|
||||
zone.zoneName,
|
||||
zone.enabled,
|
||||
zone.customUrl,
|
||||
zone.sourceCode,
|
||||
zone.url,
|
||||
zone.formData,
|
||||
zone.textInline,
|
||||
};
|
||||
|
||||
DbQuery(sqliteDb(), &ok).sql(isNew ? sqlInsertZone : sqlUpdateZone).vars(vars).executeOk();
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ bool confIp4InRange(const void *drvConf, quint32 ip, bool included, int addrGrou
|
||||
return confIpInRange(drvConf, &ip, /*isIPv6=*/false, included, addrGroupIndex);
|
||||
}
|
||||
|
||||
bool confIp6InRange(const void *drvConf, const ip6_addr_t &ip, bool included, int addrGroupIndex)
|
||||
bool confIp6InRange(const void *drvConf, const ip6_addr_t ip, bool included, int addrGroupIndex)
|
||||
{
|
||||
return confIpInRange(drvConf, &ip.addr32[0], /*isIPv6=*/true, included, addrGroupIndex);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ bool confIpInRange(const void *drvConf, const quint32 *ip, bool isIPv6 = false,
|
||||
bool included = false, int addrGroupIndex = 0);
|
||||
bool confIp4InRange(const void *drvConf, quint32 ip, bool included = false, int addrGroupIndex = 0);
|
||||
bool confIp6InRange(
|
||||
const void *drvConf, const ip6_addr_t &ip, bool included = false, int addrGroupIndex = 0);
|
||||
const void *drvConf, const ip6_addr_t ip, bool included = false, int addrGroupIndex = 0);
|
||||
|
||||
FORT_APP_DATA confAppFind(const void *drvConf, const QString &kernelPath);
|
||||
|
||||
|
@ -347,11 +347,13 @@ LabelSpinCombo *ControlUtil::createSpinCombo(int v, int min, int max, const QVec
|
||||
const QString &suffix, const std::function<void(int)> &onValueChanged)
|
||||
{
|
||||
auto c = new LabelSpinCombo();
|
||||
c->spinBox()->setRange(min, max);
|
||||
c->spinBox()->setSuffix(suffix);
|
||||
c->spinBox()->setValue(v);
|
||||
c->setValues(values);
|
||||
|
||||
auto spinBox = c->spinBox();
|
||||
spinBox->setRange(min, max);
|
||||
spinBox->setSuffix(suffix);
|
||||
spinBox->setValue(v);
|
||||
|
||||
c->connect(c->spinBox(), QOverload<int>::of(&QSpinBox::valueChanged), onValueChanged);
|
||||
|
||||
return c;
|
||||
@ -361,9 +363,11 @@ LabelSpin *ControlUtil::createSpin(int v, int min, int max, const QString &suffi
|
||||
const std::function<void(int)> &onValueChanged)
|
||||
{
|
||||
auto c = new LabelSpin();
|
||||
c->spinBox()->setRange(min, max);
|
||||
c->spinBox()->setSuffix(suffix);
|
||||
c->spinBox()->setValue(v);
|
||||
|
||||
auto spinBox = c->spinBox();
|
||||
spinBox->setRange(min, max);
|
||||
spinBox->setSuffix(suffix);
|
||||
spinBox->setValue(v);
|
||||
|
||||
c->connect(c->spinBox(), QOverload<int>::of(&QSpinBox::valueChanged), onValueChanged);
|
||||
|
||||
@ -374,9 +378,11 @@ LabelDoubleSpin *ControlUtil::createDoubleSpin(double v, double min, double max,
|
||||
const QString &suffix, const std::function<void(double)> &onValueChanged)
|
||||
{
|
||||
auto c = new LabelDoubleSpin();
|
||||
c->spinBox()->setRange(min, max);
|
||||
c->spinBox()->setSuffix(suffix);
|
||||
c->spinBox()->setValue(v);
|
||||
|
||||
auto spinBox = c->spinBox();
|
||||
spinBox->setRange(min, max);
|
||||
spinBox->setSuffix(suffix);
|
||||
spinBox->setValue(v);
|
||||
|
||||
c->connect(c->spinBox(), QOverload<double>::of(&QDoubleSpinBox::valueChanged), onValueChanged);
|
||||
|
||||
|
@ -88,9 +88,9 @@ void AutoUpdateManager::setupManager()
|
||||
void AutoUpdateManager::setupConfManager()
|
||||
{
|
||||
auto confManager = IoCDependency<ConfManager>();
|
||||
auto ini = confManager->conf()->ini();
|
||||
auto conf = confManager->conf();
|
||||
|
||||
setupByConf(ini);
|
||||
setupByConf(conf->ini());
|
||||
|
||||
connect(confManager, &ConfManager::iniChanged, this, &AutoUpdateManager::setupByConf);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace {
|
||||
|
||||
const QLoggingCategory LC("connBlockListModel");
|
||||
|
||||
QString formatIpPort(const ip_addr_t &ip, quint16 port, bool isIPv6, bool resolveAddress)
|
||||
QString formatIpPort(const ip_addr_t ip, quint16 port, bool isIPv6, bool resolveAddress)
|
||||
{
|
||||
QString address = NetUtil::ipToText(ip, isIPv6);
|
||||
if (resolveAddress) {
|
||||
|
@ -163,7 +163,7 @@ bool StatManager::updateTrafDay(qint64 unixTime)
|
||||
|
||||
bool StatManager::clearTraffic()
|
||||
{
|
||||
bool ok = true;
|
||||
bool ok;
|
||||
|
||||
beginTransaction();
|
||||
ok = sqliteDb()->execute(StatSql::sqlDeleteAllTraffic);
|
||||
|
@ -16,12 +16,12 @@ inline bool checkIp6MaskBitsCount(const int nbits)
|
||||
return (nbits >= 0 && nbits <= 128);
|
||||
}
|
||||
|
||||
bool compareLessIp6(const ip6_addr_t &l, const ip6_addr_t &r)
|
||||
inline bool compareLessIp6(const ip6_addr_t l, const ip6_addr_t r)
|
||||
{
|
||||
return memcmp(&l, &r, sizeof(ip6_addr_t)) < 0;
|
||||
}
|
||||
|
||||
void sortIp6Array(ip6_arr_t &array)
|
||||
inline void sortIp6Array(ip6_arr_t &array)
|
||||
{
|
||||
std::sort(array.begin(), array.end(), compareLessIp6);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ ip6_addr_t NetUtil::textToIp6(const char *text, bool *ok)
|
||||
return textToIp6(QString::fromLatin1(text), ok);
|
||||
}
|
||||
|
||||
QString NetUtil::ip6ToText(const ip6_addr_t &ip)
|
||||
QString NetUtil::ip6ToText(const ip6_addr_t ip)
|
||||
{
|
||||
wchar_t buf[MAX_IPV6_LEN];
|
||||
|
||||
@ -81,7 +81,7 @@ QString NetUtil::ip6ToText(const ip6_addr_t &ip)
|
||||
return QString::fromWCharArray(buf);
|
||||
}
|
||||
|
||||
QString NetUtil::ipToText(const ip_addr_t &ip, bool isIPv6)
|
||||
QString NetUtil::ipToText(const ip_addr_t ip, bool isIPv6)
|
||||
{
|
||||
return isIPv6 ? ip6ToText(ip.v6) : ip4ToText(ip.v4);
|
||||
}
|
||||
@ -96,7 +96,7 @@ quint32 NetUtil::applyIp4Mask(quint32 ip, int nbits)
|
||||
return nbits == 0 ? quint32(-1) : (ip | (nbits == 32 ? 0 : ((1 << (32 - nbits)) - 1)));
|
||||
}
|
||||
|
||||
ip6_addr_t NetUtil::applyIp6Mask(const ip6_addr_t &ip, int nbits)
|
||||
ip6_addr_t NetUtil::applyIp6Mask(const ip6_addr_t ip, int nbits)
|
||||
{
|
||||
ip6_addr_t ip6 = ip;
|
||||
quint64 *masked = &ip6.hi64;
|
||||
@ -113,7 +113,7 @@ ip6_addr_t NetUtil::applyIp6Mask(const ip6_addr_t &ip, int nbits)
|
||||
return ip6;
|
||||
}
|
||||
|
||||
QByteArray NetUtil::ip6ToRawArray(const ip_addr_t &ip)
|
||||
QByteArray NetUtil::ip6ToRawArray(const ip_addr_t ip)
|
||||
{
|
||||
return QByteArray::fromRawData(ip.v6.data, sizeof(ip6_addr_t));
|
||||
}
|
||||
|
@ -21,17 +21,17 @@ public:
|
||||
static ip6_addr_t textToIp6(const char *text, bool *ok = nullptr);
|
||||
|
||||
// Convert IPv6 address from number to text
|
||||
static QString ip6ToText(const ip6_addr_t &ip);
|
||||
static QString ip6ToText(const ip6_addr_t ip);
|
||||
|
||||
static QString ipToText(const ip_addr_t &ip, bool isIPv6 = false);
|
||||
static QString ipToText(const ip_addr_t ip, bool isIPv6 = false);
|
||||
|
||||
// Get IPv4 address mask
|
||||
static int ip4Mask(quint32 ip);
|
||||
|
||||
static quint32 applyIp4Mask(quint32 ip, int nbits);
|
||||
static ip6_addr_t applyIp6Mask(const ip6_addr_t &ip, int nbits);
|
||||
static ip6_addr_t applyIp6Mask(const ip6_addr_t ip, int nbits);
|
||||
|
||||
static QByteArray ip6ToRawArray(const ip_addr_t &ip);
|
||||
static QByteArray ip6ToRawArray(const ip_addr_t ip);
|
||||
static const ip6_addr_t &rawArrayToIp6(const QByteArray &buf);
|
||||
|
||||
static QString getHostName(const QString &address);
|
||||
|
Loading…
Reference in New Issue
Block a user