Skip to content

fix: clear mapInfo on getMapInfo failure - #766

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:agent/pms-bug-bot/fdcf302839d3
Sep 17, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:agent/pms-bug-bot/fdcf302839d3

Conversation

@add-uos

@add-uos add-uos commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

fix: clear mapInfo on getMapInfo failure

  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

Summary by Sourcery

Clear device metadata when getMapInfo rejects a device and verify the failure output is empty.

Bug Fixes:

  • Ensure getMapInfo clears its output map before returning false for unsupported, hub, or missing-BusID devices.

Enhancements:

  • Strengthen the getMapInfo failure contract so callers never receive stale device metadata.

Tests:

  • Update EnableUtils and WakeupUtils tests to verify failed lookups return an empty map.

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @add-uos, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 6 hours and 4 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Strengthens 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 clearing

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Clear parsed device metadata before rejecting unsupported or incomplete devices, enforcing an empty output map on every failure path.
  • Clear hub and missing-SysFS-BusID results in EnableUtils.
  • Clear non-keyboard/non-mouse results in WakeupUtils.
deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enableutils.cpp
deepin-devicemanager-server/deepin-devicecontrol/src/wakecontrol/wakeuputils.cpp
Update unit tests to verify failed lookups do not expose partially parsed metadata.
  • Assert empty maps for hub, missing-BusID, and unsupported-device cases while retaining success coverage.
deepin-devicemanager-server/tests/src/EnableControl/ut_enableutils.cpp
deepin-devicemanager-server/tests/src/WakeControl/ut_wakeuputils.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 100 分,大于 70 分通过阈值。本次提交修复了 getMapInfo 返回失败时未清空输出参数 mapInfo 的问题,变更范围小且聚焦,测试同步更新,代码质量优秀。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 语法正确,逻辑清晰,无需改进


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 代码结构清晰,注释完整,无需改进


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 性能良好,资源使用合理,无需改进


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 存在0个安全漏洞,安全合规,无需改进


💡 改进建议代码示例

// 暂无代码示例

本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@add-uos

add-uos commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 9ab83ae into linuxdeepin:master Sep 17, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants