Skip to content

Feat: [cpu] Add max boost clock item on special cpu type. - #713

Closed
add-uos wants to merge 0 commit into
linuxdeepin:masterfrom
add-uos:master
Closed

Feat: [cpu] Add max boost clock item on special cpu type.#713
add-uos wants to merge 0 commit into
linuxdeepin:masterfrom
add-uos:master

Conversation

@add-uos

@add-uos add-uos commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

-- Add max boost clock item on special cpu type.

pick from: 6924401

Log: add feature
Task: https://pms.uniontech.com/task-view-384577.html

@github-actions

Copy link
Copy Markdown
  • 检测到敏感词dmidecode变动
详情
    {
    "dmidecode": {
        "deepin-devicemanager/src/DeviceManager/DeviceCpu.cpp": [
            "    // \u7279\u6b8a\u673a\u578b\uff0c\u901a\u8fc7 dmidecode \u83b7\u53d6\u6700\u5927\u52a0\u901f\u9891\u7387"
        ]
    }
}

@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 have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码实现了特定机型CPU最大加速频率的获取与展示,逻辑清晰且满足需求。
逻辑正确但因代码重复及缺少边界检查扣5分。

■ 【详细分析】

  • 1.语法逻辑(基本正确)✓

代码在main.cpp中读取DConfig并使用static_cast进行类型转换,在DeviceCpu.cpp中通过条件判断追加表头和表数据。整体语法正确,能够正常编译运行。
潜在问题:在main.cppstatic_cast<Common::SpecialCpuType>(dconfig->value("specialCpuType").toInt())未对读取的整数值进行枚举边界校验,若配置文件被篡改为非预期值,可能导致枚举变量持有无效值。
建议:在进行类型转换前,增加对读取值的合法性校验,确保其处于枚举定义的范围内。

  • 2.代码质量(一般)✕

DeviceCpu.cpploadTableHeaderloadTableData函数中,分别使用了相同的条件判断if (Common::curCpuType == Common::kSpecialCpuType1),存在轻微的代码重复。
潜在问题:如果未来需要增加更多特殊CPU类型或修改判断条件,需要在多处进行同步修改,增加了维护成本。
建议:考虑将公共的判断逻辑提取为一个辅助函数,或者在类内部封装一个方法来判断是否需要显示最大加速频率。

  • 3.代码性能(无性能问题)✓

新增的代码仅涉及简单的条件判断、字符串追加和类型转换,且仅在初始化阶段执行一次,不会对程序运行性能产生负面影响。
潜在问题:
建议:保持现状即可。

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次代码变更未引入命令注入、缓冲区溢出或敏感信息泄露等安全风险。DConfig配置项的读取与转换在受控范围内进行,不涉及外部不可信输入的直接执行。

  • 建议:无需额外修复措施。

■ 【改进建议代码示例】

// main.cpp
if(dconfig && dconfig->isValid()) {
    if (dconfig->keyList().contains("specialComType"))
        Common::specialComType = dconfig->value("specialComType").toInt();
    if (dconfig->keyList().contains("TomlFilesName")) {
        QString tomlFilesName = dconfig->value("TomlFilesName").toString();
        Common::tomlFilesNameSet(tomlFilesName);
    }
    if (dconfig->keyList().contains("specialCpuType")) {
        int cpuTypeValue = dconfig->value("specialCpuType").toInt();
        // 增加枚举边界校验
        if (cpuTypeValue >= Common::kUnknowCpuType && cpuTypeValue <= Common::kSpecialCpuType1) {
            Common::curCpuType = static_cast<Common::SpecialCpuType>(cpuTypeValue);
        } else {
            Common::curCpuType = Common::kUnknowCpuType;
        }
    }
}

// DeviceCpu.cpp
// 可以考虑增加一个内联函数或宏来简化判断,例如:
// bool DeviceCpu::isSpecialCpuType1() const { return Common::curCpuType == Common::kSpecialCpuType1; }
// 然后在 loadTableHeader 和 loadTableData 中调用 isSpecialCpuType1()

@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

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