Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion apps/ll-driver-detect/src/driver_detection_config.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2025 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand Down Expand Up @@ -64,6 +64,11 @@
file << jsonConfig.dump(4); // Pretty print with 4 spaces
file.close();

if (!file.good()) {
LogW("failed to write driver detection config to {}", configFilePath);
return false;
}

Check warning on line 70 in apps/ll-driver-detect/src/driver_detection_config.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'recordUserChoice' is never used.

return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
* SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
Expand Down Expand Up @@ -69,3 +69,14 @@ TEST_F(DriverDetectionConfigTest, SaveAndLoadConfig)
auto loadedConfig = manager2.getConfig();
EXPECT_TRUE(loadedConfig.neverRemind);
}

TEST_F(DriverDetectionConfigTest, SaveConfigFailsOnWriteError)
{
using namespace linglong::driver::detect;

// Opening /dev/full succeeds but every write fails with ENOSPC; if the
// device is unavailable the open itself fails, so the save must report
// failure either way instead of silently losing the user's choice
DriverDetectionConfigManager manager("/dev/full");
EXPECT_FALSE(manager.saveConfig());
}
Loading