Repository navigation
fix(storage): widen disk size matching tolerance to ±2 GB - #981
Conversation
Adjust the nominal disk capacity boundaries in checkDiskSize() from ±1 GB to ±2 GB so that storage devices whose reported byte count deviates slightly more from the nominal value are still matched to the standard 256 GB / 512 GB / 1 TB / 2 TB labels. 将 checkDiskSize() 中磁盘容量匹配的上下限容差从 ±1 GB 调整为 ±2 GB,使上报字节数偏离标称值稍大的存储设备仍能匹配到标准的 256 GB / 512 GB / 1 TB / 2 TB 标签。 Log: 调整磁盘容量匹配上下限至±2GB PMS: 372871 Influence: checkDiskSize 的容量匹配逻辑,影响定制机型存储设备的容量显示规范化
Reviewer's GuideImplementationWiden the disk-size thresholds in checkDiskSize() so capacities within ±2 GB of the standard values receive the corresponding labels.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp" line_range="608" />
<code_context>
// if (m_Interface.contains("UFS", Qt::CaseInsensitive)) { // TODO Ignore ufs disk
- if (m_SizeBytes > 255*gbyte && m_SizeBytes < 257*gbyte) {
+ if (m_SizeBytes > 254*gbyte && m_SizeBytes < 258*gbyte) {
m_Size = "256 GB";
- } else if (m_SizeBytes > 511*gbyte && m_SizeBytes < 513*gbyte) {
</code_context>
<issue_to_address>
**Endpoint capacities keep raw labels**
When a device reports a capacity exactly at a widened range limit, `checkDiskSize()` uses strict `>` and `<` comparisons, so `m_SizeBytes` at a lower or upper limit does not match the range and `m_Size` keeps its unnormalized value instead of receiving the standard label.
Make the widened range comparisons inclusive at both endpoints.
Also at `deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp:610-614`.
</issue_to_address>|
|
||
| // if (m_Interface.contains("UFS", Qt::CaseInsensitive)) { // TODO Ignore ufs disk | ||
| if (m_SizeBytes > 255*gbyte && m_SizeBytes < 257*gbyte) { | ||
| if (m_SizeBytes > 254*gbyte && m_SizeBytes < 258*gbyte) { |
There was a problem hiding this comment.
🟡 Medium · Endpoint capacities keep raw labels
When a device reports a capacity exactly at a widened range limit, checkDiskSize() uses strict > and < comparisons, so m_SizeBytes at a lower or upper limit does not match the range and m_Size keeps its unnormalized value instead of receiving the standard label.
Make the widened range comparisons inclusive at both endpoints.
Also at deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp:610-614.
Prompt for AI agents
In `deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp` at line 608:
**Endpoint capacities keep raw labels**
When a device reports a capacity exactly at a widened range limit, `checkDiskSize()` uses strict `>` and `<` comparisons, so `m_SizeBytes` at a lower or upper limit does not match the range and `m_Size` keeps its unnormalized value instead of receiving the standard label.
Make the widened range comparisons inclusive at both endpoints.
Also at `deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp:610-614`.
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['无需修改,逻辑正确。'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['可选优化:将 gbyte、标称容量阈值等常量提取为命名常量或枚举,提升可维护性,但非本次必须。'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: ['无性能优化建议。'] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: ['无安全加固建议。'] 💡 改进建议代码示例// 当前实现已正确,无需修复。如需进一步提升可维护性,可将标称容量阈值定义为命名常量: // // const quint64 gbyte = 1000000000; // const quint64 tolerance = 2 * gbyte; // const quint64 nominal_256gb = 256 * gbyte; // if (m_SizeBytes > nominal_256gb - tolerance && m_SizeBytes < nominal_256gb + tolerance) { // m_Size = "256 GB"; // } // ...其余区间同理本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind 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: unstable) |
Backport of #722 (merged into release/1071) to master.
Adjust the nominal disk capacity boundaries in checkDiskSize() from ±1 GB to ±2 GB so that storage devices whose reported byte count deviates slightly more from the nominal value are still matched to the standard 256 GB / 512 GB / 1 TB / 2 TB labels.
将 checkDiskSize() 中磁盘容量匹配的上下限容差从 ±1 GB 调整为 ±2 GB,使上报字节数偏离标称值稍大的存储设备仍能匹配到标准的 256 GB / 512 GB / 1 TB / 2 TB 标签。
Log: 调整磁盘容量匹配上下限至±2GB
PMS: 372871
Influence: checkDiskSize 的容量匹配逻辑,影响定制机型存储设备的容量显示规范化
Summary by Sourcery
Bug Fixes: