fix: clear mapInfo on getMapInfo failure - #766
Merged
deepin-bot[bot] merged 1 commit intoSep 17, 2026
Merged
Conversation
1. Root cause: getMapInfo in WakeupUtils and EnableUtils parses all lines into the output mapInfo before condition checks, leaving stale data when returning false 2. Fix: add mapInfo.clear() before every return false path after the parsing loop so the output parameter is always empty on failure 3. Impact: existing callers already skip on false, no behavior change for them; API contract strengthened for future callers Influence: 1. Verify getMapInfo returns false with empty mapInfo for non-keyboard or mouse devices 2. Verify getMapInfo returns false with empty mapInfo for hub devices 3. Verify getMapInfo returns false with empty mapInfo for devices without SysFS BusID fix: 修复 getMapInfo 返回失败时未清空输出参数 1. 根因:WakeupUtils 和 EnableUtils 的 getMapInfo 在条件检查前 已将所有行解析到输出参数 mapInfo,返回 false 时残留脏数据 2. 方案:在解析循环后的所有 return false 路径前增加 mapInfo.clear 确保输出参数在失败时为空 3. 影响:现有调用方在 false 时已 continue 跳过,行为无变化; API 契约得到强化 Influence: 1. 验证非键盘鼠标设备时 getMapInfo 返回 false 且 mapInfo 为空 2. 验证 hub 设备时 getMapInfo 返回 false 且 mapInfo 为空 3. 验证无 SysFS BusID 设备时 getMapInfo 返回 false 且 mapInfo 为空 PMS: BUG-4584
Reviewer's guide (collapsed on small PRs)Reviewer's GuideStrengthens getMapInfo’s failure contract by clearing mapInfo after parsing but before each rejection return, and updates tests to assert empty output for unsupported, hub, and missing-BusID devices. Sequence diagram for getMapInfo failure output clearingsequenceDiagram
participant Caller
participant getMapInfo
participant mapInfo
Caller->>getMapInfo: getMapInfo(item, mapInfo)
getMapInfo->>mapInfo: parse device properties
alt unsupported hardware class
getMapInfo->>mapInfo: clear()
getMapInfo-->>Caller: false
else hub device or missing SysFS BusID
getMapInfo->>mapInfo: clear()
getMapInfo-->>Caller: false
else supported device
getMapInfo-->>Caller: true with mapInfo
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 语法正确,逻辑清晰,无需改进 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 代码结构清晰,注释完整,无需改进 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: 性能良好,资源使用合理,无需改进 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 存在0个安全漏洞,安全合规,无需改进 💡 改进建议代码示例// 暂无代码示例本报告由 AI 代码审查工具自动生成 |
lzwind
approved these changes
Sep 17, 2026
|
[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 |
Contributor
Author
|
/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: clear mapInfo on getMapInfo failure
lines into the output mapInfo before condition checks, leaving
stale data when returning false
parsing loop so the output parameter is always empty on failure
for them; API contract strengthened for future callers
Influence:
or mouse devices
without SysFS BusID
fix: 修复 getMapInfo 返回失败时未清空输出参数
已将所有行解析到输出参数 mapInfo,返回 false 时残留脏数据
确保输出参数在失败时为空
API 契约得到强化
Influence:
PMS: BUG-4584
Summary by Sourcery
Clear device metadata when getMapInfo rejects a device and verify the failure output is empty.
Bug Fixes:
Enhancements:
Tests: