fix: [Stroage-interface] support UFS 4.1 spec_version 410 - #214
Conversation
There was a problem hiding this comment.
Sorry @tianming-1996, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Reviewer's GuideAdd support for detecting UFS 4.1 (spec_version 410) and harden hwinfo output parsing by using a key-value map, with unit tests to validate the new parsing behavior around the "Attached to" and "Capacity" lines. Sequence diagram for updated getDiskInfoInterface hwinfo parsingsequenceDiagram
participant DeviceStorage
participant HwinfoProcess
participant getMapInfoFromInput
DeviceStorage->>HwinfoProcess: start(cmd)
DeviceStorage->>HwinfoProcess: waitForFinished(-1)
DeviceStorage->>HwinfoProcess: readAllStandardOutput()
HwinfoProcess-->>DeviceStorage: outPut
DeviceStorage->>getMapInfoFromInput: getMapInfoFromInput(outPut, mapInfo)
getMapInfoFromInput-->>DeviceStorage: mapInfo
DeviceStorage->>DeviceStorage: mapInfo.value(Attached to)
DeviceStorage->>DeviceStorage: split("(") and extract interface
Flow diagram for UFS spec_version detection including 410flowchart TD
A[read spec_version] --> B{spec_version contains 300
or 310
or 400
or 410}
B -->|yes| C[interface = UFS]
B -->|no| D[interface unchanged]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
d2a4e9d to
03dd5ca
Compare
|
-2, 硬代码,重新搞,基于d-config 搞 |
3d48b35 to
dc7d25a
Compare
0709458 to
738738b
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配置驱动 Bug: https://pms.uniontech.com/bug-view-372777.html Influence: UFS接口识别逻辑改为配置驱动,新增UFS版本无需改源码,提升可维护性。
738738b to
a24ab38
Compare
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // service/diskoperation/DeviceStorage.cpp
void DeviceStorage::getDiskInfoInterface(const QString &devicePath, QString &interface, QString &model)
{
QString bootDevicePath("/proc/bootdevice/product_name");
// ... 省略前置 UFS spec_version 读取与匹配逻辑 ...
if (!spec_version.isEmpty()) {
// 建议:使用范围 for 循环替代 Qt 的 foreach 宏,提升现代 C++ 代码风格一致性
for (const QString &version : ufsSpecVersions()) {
if (spec_version.contains(version)) {
interface = "UFS";
break;
}
}
}
// ... 省略中间逻辑 ...
// 【BUG 修复核心点】增强防御性编程
QMap<QString, QString> mapInfo;
getMapInfoFromInput(outPut, mapInfo);
const QString attachedTo = mapInfo.value("Attached to");
// 建议增加非空校验,使逻辑意图更明确,避免潜在的未来修改引入越界风险
if (!attachedTo.isEmpty()) {
QStringList outPutList = attachedTo.split("(");
if (!outPutList.isEmpty()) {
// 使用 last() 和 value(0) 替代直接下标访问,更加安全
interface = outPutList.last().split(" ").value(0);
}
}
return;
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: max-lvs, tianming-1996 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 |
|
/merge |
Add spec_version "410" to UFS detection and use getMapInfoFromInput to parse "Attached to" field instead of raw output split.
补充UFS 4.1 (spec_version 410) 的识别,修正hwinfo输出解析逻辑。
Log: 支持UFS 4.1接口识别
Bug: https://pms.uniontech.com/bug-view-372777.html
Influence: PGUY机型UFS 4.1存储设备接口可正确识别为UFS。
Summary by Sourcery
Extend disk interface detection to correctly recognize UFS devices and improve robustness of hwinfo output parsing.
New Features:
Bug Fixes:
Tests: