Skip to content

fix: clear boardVendorKey cache in else branch - #874

Closed
add-uos wants to merge 1 commit into
linuxdeepin:masterfrom
add-uos:agent/bug/eae1d1ac35a8
Closed

add-uos wants to merge 1 commit into
linuxdeepin:masterfrom
add-uos:agent/bug/eae1d1ac35a8

Conversation

@add-uos

@add-uos add-uos commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

fix: clear boardVendorKey cache in else branch

  1. Root cause: static variable boardVendorKey was not cleared in the
    else branch of checkBoardVendorFlag() when dmidecode output did not
    match any known model string, causing stale cache values to persist
    across calls
  2. Fix: add boardVendorKey.clear() at the entry of the else branch to
    reset the static variable before dmidecode matching logic runs
  3. Impact: stale non-empty values no longer mask the M900/W525 fallback
    check at line 206; only the else branch is affected, the switch
    branch and other functions remain unchanged

Influence:

  1. Test checkBoardVendorFlag on unknown device models to verify
    boardVendorKey is empty after call
  2. Test M900/W525 fallback logic triggers correctly after unknown model
  3. Verify known model detection (KLVV/KLVU/PGUV/PGUW/PGUX) still works

fix: 修复else分支中boardVendorKey缓存残留问题

  1. 根因:checkBoardVendorFlag()的else分支中,当dmidecode输出不匹配
    任何已知机型字符串时,未清空静态变量boardVendorKey,导致旧值跨
    调用残留
  2. 方案:在else分支入口处添加boardVendorKey.clear(),在进入dmidecode
    匹配逻辑前重置静态变量
  3. 影响:残留的非空值不再屏蔽第206行M900/W525兜底检查,仅影响else
    分支行为,switch分支和其他函数不受影响

Influence:

  1. 测试未知机型设备上调用checkBoardVendorFlag后boardVendorKey为空
  2. 测试M900/W525兜底逻辑在未知机型后能正确触发
  3. 验证已知机型检测(KLVV/KLVU/PGUV/PGUW/PGUX)功能正常

Summary by Sourcery

Bug Fixes:

  • Clear the cached board vendor key for unknown device models so stale values cannot suppress the M900/W525 fallback detection.

1. Root cause: static variable boardVendorKey was not cleared in the
   else branch of checkBoardVendorFlag() when dmidecode output did not
   match any known model string, causing stale cache values to persist
   across calls
2. Fix: add boardVendorKey.clear() at the entry of the else branch to
   reset the static variable before dmidecode matching logic runs
3. Impact: stale non-empty values no longer mask the M900/W525 fallback
   check at line 206; only the else branch is affected, the switch
   branch and other functions remain unchanged

Influence:
1. Test checkBoardVendorFlag on unknown device models to verify
   boardVendorKey is empty after call
2. Test M900/W525 fallback logic triggers correctly after unknown model
3. Verify known model detection (KLVV/KLVU/PGUV/PGUW/PGUX) still works

fix: 修复else分支中boardVendorKey缓存残留问题

1. 根因:checkBoardVendorFlag()的else分支中,当dmidecode输出不匹配
   任何已知机型字符串时,未清空静态变量boardVendorKey,导致旧值跨
   调用残留
2. 方案:在else分支入口处添加boardVendorKey.clear(),在进入dmidecode
   匹配逻辑前重置静态变量
3. 影响:残留的非空值不再屏蔽第206行M900/W525兜底检查,仅影响else
   分支行为,switch分支和其他函数不受影响

Influence:
1. 测试未知机型设备上调用checkBoardVendorFlag后boardVendorKey为空
2. 测试M900/W525兜底逻辑在未知机型后能正确触发
3. 验证已知机型检测(KLVV/KLVU/PGUV/PGUW/PGUX)功能正常
@sourcery-ai

sourcery-ai Bot commented Oct 23, 2026

Copy link
Copy Markdown

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 5 days and 4 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@deepin-ci-robot

Copy link
Copy Markdown

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

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

@sourcery-ai

sourcery-ai Bot commented Oct 23, 2026

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

Reviewer's Guide

The PR fixes stale boardVendorKey state by clearing it before unknown-model detection, allowing the M900/W525 fallback to run correctly without changing known-model or switch-branch handling.

Sequence diagram for board vendor flag cache reset

sequenceDiagram
    participant Caller
    participant Common
    participant Dmidecode
    participant boardVendorKey

    Caller->>Common: checkBoardVendorFlag()
    alt switch branch
        Common-->>Caller: return existing switch result
    else unknown-model branch
        Common->>boardVendorKey: clear()
        Common->>Dmidecode: start(-s system-product-name)
        Dmidecode-->>Common: product name
        alt known model match
            Common->>boardVendorKey: assign detected key
        else M900 or W525 fallback
            Common-->>Caller: return fallback result
        end
        Common-->>Caller: return detection result
    end
Loading

File-Level Changes

Change Details Files
Reset the cached board vendor key before evaluating dmidecode output in the non-switch path.
  • Clear the static cache at the else-branch entry.
  • Preserve existing dmidecode matching and fallback behavior while preventing stale values from affecting subsequent calls.
deepin-devicemanager/src/commonfunction.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


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交在 checkBoardVendorFlag() 函数的 else 分支开头添加 boardVendorKey.clear(), 修复了缓存不一致的 bug。变更仅一行,语法正确,逻辑清晰,无安全漏洞,无性能影响, 代码质量良好。启发式扫描、OCR 审查与 AI 四维度分析均未发现问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

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

建议: 无


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

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

建议: 无


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

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

建议: 无


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 无


💡 改进建议代码示例

// 当前修复已正确,无需额外修改 }else{
    boardVendorKey.clear();
    QProcess process;
    process.start("dmidecode", QStringList() << "-s" << "system-product-name");
    process.waitForFinished(-1);

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

@add-uos add-uos closed this Oct 26, 2026
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.

2 participants