From 67c6167a1adff1c01e52a1b36670b82f3329cfe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E9=82=A3=E5=87=A0?= <2078634206@qq.com> Date: Wed, 30 Sep 2026 13:17:11 +0800 Subject: [PATCH 1/2] fix(ll-driver-detect): detect config write failures in saveConfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit saveConfig() only checked that the file opened; a failed write or close (e.g. ENOSPC) still returned true so the user's choice could silently fail to persist. Check the stream state after closing and return false on failure. Add a unit test using /dev/full. Signed-off-by: 陈那几 <2078634206@qq.com> --- apps/ll-driver-detect/src/driver_detection_config.cpp | 5 +++++ .../ll-driver-detect/driver_detection_config_test.cpp | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/apps/ll-driver-detect/src/driver_detection_config.cpp b/apps/ll-driver-detect/src/driver_detection_config.cpp index daf06f297..16e3a5a0a 100644 --- a/apps/ll-driver-detect/src/driver_detection_config.cpp +++ b/apps/ll-driver-detect/src/driver_detection_config.cpp @@ -64,6 +64,11 @@ bool DriverDetectionConfigManager::saveConfig() 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; + } + return true; } diff --git a/libs/linglong/tests/ll-tests/src/apps/ll-driver-detect/driver_detection_config_test.cpp b/libs/linglong/tests/ll-tests/src/apps/ll-driver-detect/driver_detection_config_test.cpp index 042b228a0..97ffed311 100644 --- a/libs/linglong/tests/ll-tests/src/apps/ll-driver-detect/driver_detection_config_test.cpp +++ b/libs/linglong/tests/ll-tests/src/apps/ll-driver-detect/driver_detection_config_test.cpp @@ -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()); +} From 7e34b3ed13997f78bd2808a2f743582897e39a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E9=82=A3=E5=87=A0?= <2078634206@qq.com> Date: Thu, 1 Oct 2026 03:27:41 +0800 Subject: [PATCH 2/2] chore: align copyright headers with the SPDX year checker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extend the modified source file copyright range to 2026 and use the single current year for the newly added test file, as required by the SPDX Year Range Checker in the license-check workflow. No code change. Signed-off-by: 陈那几 <2078634206@qq.com> --- apps/ll-driver-detect/src/driver_detection_config.cpp | 2 +- .../src/apps/ll-driver-detect/driver_detection_config_test.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/ll-driver-detect/src/driver_detection_config.cpp b/apps/ll-driver-detect/src/driver_detection_config.cpp index 16e3a5a0a..74d8f786a 100644 --- a/apps/ll-driver-detect/src/driver_detection_config.cpp +++ b/apps/ll-driver-detect/src/driver_detection_config.cpp @@ -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 diff --git a/libs/linglong/tests/ll-tests/src/apps/ll-driver-detect/driver_detection_config_test.cpp b/libs/linglong/tests/ll-tests/src/apps/ll-driver-detect/driver_detection_config_test.cpp index 97ffed311..8e891cd2d 100644 --- a/libs/linglong/tests/ll-tests/src/apps/ll-driver-detect/driver_detection_config_test.cpp +++ b/libs/linglong/tests/ll-tests/src/apps/ll-driver-detect/driver_detection_config_test.cpp @@ -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 */