UI: Fix ConfBuffer::write() result's using

This commit is contained in:
Nodir Temirkhodjaev 2024-10-27 17:56:18 +05:00
parent 53bb7f48ad
commit 190bb5bcc0
3 changed files with 6 additions and 8 deletions

View File

@ -70,10 +70,10 @@ void setConf(Device &device)
ConfBuffer confBuf;
const int confIoSize = confBuf.write(conf, nullptr, envManager);
ASSERT_NE(confIoSize, 0);
ASSERT_TRUE(confBuf.write(conf, nullptr, envManager));
ASSERT_TRUE(device.ioctl(DriverCommon::ioctlSetConf(), confBuf.data(), confIoSize));
auto confData = confBuf.buffer();
ASSERT_TRUE(device.ioctl(DriverCommon::ioctlSetConf(), confData.data(), confData.size()));
}
void printLogs(LogBuffer &buf)

View File

@ -69,10 +69,9 @@ TEST_F(ConfUtilTest, confWriteRead)
ConfBuffer confBuf;
const int confIoSize = confBuf.write(conf, nullptr, envManager);
if (confIoSize == 0) {
if (!confBuf.write(conf, nullptr, envManager)) {
qCritical() << "Error:" << confBuf.errorMessage();
ASSERT_NE(confIoSize, 0);
Q_UNREACHABLE();
}
// Check the buffer

View File

@ -903,8 +903,7 @@ bool ConfManager::validateConf(const FirewallConf &newConf)
ConfBuffer confBuf;
const int confSize = confBuf.write(newConf, IoC<ConfAppManager>(), *IoC<EnvManager>());
if (confSize == 0) {
if (!confBuf.write(newConf, IoC<ConfAppManager>(), *IoC<EnvManager>())) {
qCCritical(LC) << "Conf save error:" << confBuf.errorMessage();
return false;
}