Repository navigation
fix(storage): read UFS spec versions from DConfig instead of hardcoding - #258
Conversation
Reviewer's GuideImplementationLoad configured UFS spec-version substrings with fallback defaults and parse hwinfo's Attached to field explicitly to avoid mistaking capacity output for the interface.
ConfigurationAdd and install the DConfig schema containing UFS version settings, and declare the new assets in the reuse annotations.
TestsLink the Dtk Core dependency in the test target and add coverage for Attached to parsing and missing interface data.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="service/diskoperation/DeviceStorage.cpp" line_range="772" />
<code_context>
- if (spec_version.contains("300") || spec_version.contains("310") || spec_version.contains("400")) {
- interface = "UFS";
+ foreach (const QString &version, ufsSpecVersions()) {
+ if (spec_version.contains(version)) {
+ interface = "UFS";
+ break;
</code_context>
<issue_to_address>
**Non-UFS boot disks appear as UFS**
When the configured `ufsSpecVersions()` list contains an empty string and a boot device has a nonempty spec version, `getDiskInfoInterface` passes the empty version to `QString::contains`, which matches every nonempty `spec_version` and sets `interface` to UFS, so callers see non-UFS boot storage reported as UFS.
Skip empty entries in the version list before matching them against `spec_version`.
</issue_to_address>
### Comment 2
<location path="service/diskoperation/DeviceStorage.cpp" line_range="751-756" />
<code_context>
+ QScopedPointer<Dtk::Core::DConfig> cfg(
+ Dtk::Core::DConfig::create("com.deepin.diskmanager", "com.deepin.diskmanager.storage"));
+ if (cfg && cfg->isValid()) {
+ QStringList versions = cfg->value("ufsSpecVersions", QVariant::fromValue(fallback)).toStringList();
+ if (!versions.isEmpty())
+ return versions;
+ }
+ return fallback;
+}
</code_context>
<issue_to_address>
**Configured versions silently ignored**
When DConfig is unavailable or invalid and a device uses a spec-version substring added only through DConfig, `ufsSpecVersions()` returns the hardcoded fallback without logging that DConfig is invalid, so versions added only through DConfig are not matched and affected devices can be reported with the wrong interface.
Log a warning when DConfig cannot be loaded or validated before using the fallback list.
</issue_to_address>| if (spec_version.contains("300") || spec_version.contains("310") || spec_version.contains("400")) { | ||
| interface = "UFS"; | ||
| foreach (const QString &version, ufsSpecVersions()) { | ||
| if (spec_version.contains(version)) { |
There was a problem hiding this comment.
🟡 Medium · Non-UFS boot disks appear as UFS
When the configured ufsSpecVersions() list contains an empty string and a boot device has a nonempty spec version, getDiskInfoInterface passes the empty version to QString::contains, which matches every nonempty spec_version and sets interface to UFS, so callers see non-UFS boot storage reported as UFS.
Skip empty entries in the version list before matching them against spec_version.
Prompt for AI agents
In `service/diskoperation/DeviceStorage.cpp` at line 772:
**Non-UFS boot disks appear as UFS**
When the configured `ufsSpecVersions()` list contains an empty string and a boot device has a nonempty spec version, `getDiskInfoInterface` passes the empty version to `QString::contains`, which matches every nonempty `spec_version` and sets `interface` to UFS, so callers see non-UFS boot storage reported as UFS.
Skip empty entries in the version list before matching them against `spec_version`.| QStringList versions = cfg->value("ufsSpecVersions", QVariant::fromValue(fallback)).toStringList(); | ||
| if (!versions.isEmpty()) | ||
| return versions; | ||
| } | ||
| return fallback; | ||
| } |
There was a problem hiding this comment.
🟡 Medium · Configured versions silently ignored
When DConfig is unavailable or invalid and a device uses a spec-version substring added only through DConfig, ufsSpecVersions() returns the hardcoded fallback without logging that DConfig is invalid, so versions added only through DConfig are not matched and affected devices can be reported with the wrong interface.
Log a warning when DConfig cannot be loaded or validated before using the fallback list.
Prompt for AI agents
In `service/diskoperation/DeviceStorage.cpp` at lines 751-756:
**Configured versions silently ignored**
When DConfig is unavailable or invalid and a device uses a spec-version substring added only through DConfig, `ufsSpecVersions()` returns the hardcoded fallback without logging that DConfig is invalid, so versions added only through DConfig are not matched and affected devices can be reported with the wrong interface.
Log a warning when DConfig cannot be loaded or validated before using the fallback list.|
TAG Bot New tag: 6.0.29 |
a7e1973 to
1017864
Compare
Read UFS spec_version substrings from DConfig so new UFS versions can be added via configuration without source code changes. 从 DConfig 读取 UFS spec_version 子串列表,新增 UFS 版本时只需 在配置中追加,无需修改源码。 Log: UFS版本识别改为DConfig配置驱动 PMS: BUG-372777 Influence: UFS接口识别逻辑改为配置驱动,新增UFS版本无需改源码,提升可维护性。
1017864 to
80d6e39
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
1 similar comment
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Backport of #214 (merged into release/1071) to master.
Read UFS spec_version substrings from DConfig so new UFS versions can be added via configuration without source code changes. Also parse the hwinfo "Attached to" field via getMapInfoFromInput instead of raw output split.
从 DConfig 读取 UFS spec_version 子串列表,新增 UFS 版本时只需在配置中追加,无需修改源码;hwinfo 输出改用 getMapInfoFromInput 解析 "Attached to" 字段,避免从容量行误识别接口。
Cherry-picked from release/1071 (e4a72be) with adaptations:
Log: UFS版本识别改为DConfig配置驱动
PMS: BUG-372777
Influence: UFS接口识别逻辑改为配置驱动,新增UFS版本无需改源码,PGUY机型UFS 4.1存储设备接口可正确识别为UFS。
Summary by Sourcery
Make UFS interface recognition configuration-driven and reliably parse hwinfo controller information.
New Features:
Bug Fixes:
Enhancements:
Build:
Tests:
Chores: