feat: Adjust CPU frequency values for kSpecialType7 device#535
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom Sep 15, 2025
Merged
feat: Adjust CPU frequency values for kSpecialType7 device#535deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom
Conversation
Modified CPU frequency display for kSpecialType7 devices include current frequency and max frequency to correct hardware reporting inaccuracies. Log: Fix CPU frequency display for special device type Task: https://pms.uniontech.com/task-view-381765.html Change-Id: Id37a4b03a83ccb6428a1bd3edf601d905edbd2c8
deepin pr auto review我对这段代码进行审查,发现以下几个需要改进的地方:
改进建议: // 在类定义中添加常量定义
static const QString CPU_FREQUENCY_CORRECTION_VALUE = "2.189";
static const QString CPU_MAX_FREQUENCY_CORRECTION_VALUE = "2189";
static const QString CPU_FREQUENCY_CORRECTED_VALUE = "2.188";
static const QString CPU_MAX_FREQUENCY_CORRECTED_VALUE = "2188";
// 添加输入验证函数
bool DeviceCpu::isValidInput(const QMap<QString, QString> &map) const {
return !map.isEmpty();
}
// 封装特殊类型的处理逻辑
void DeviceCpu::handleSpecialTypeCorrection() {
if (Common::specialComType == Common::kSpecialType5 ||
Common::specialComType == Common::kSpecialType6 ||
Common::specialComType == Common::kSpecialType7) {
m_Frequency.replace(CPU_FREQUENCY_CORRECTION_VALUE, CPU_FREQUENCY_CORRECTED_VALUE);
m_MaxFrequency.replace(CPU_MAX_FREQUENCY_CORRECTION_VALUE, CPU_MAX_FREQUENCY_CORRECTED_VALUE);
}
}
// 改进后的setCpuInfo函数
void DeviceCpu::setCpuInfo(const QMap<QString, QString> &mapLscpu, const QMap<QString, QString> &mapCpuinfo) {
// 输入验证
if (!isValidInput(mapLscpu) || !isValidInput(mapCpuinfo)) {
qWarning() << "Invalid input maps in DeviceCpu::setCpuInfo";
return;
}
// 原有逻辑...
// 使用封装的特殊类型处理函数
handleSpecialTypeCorrection();
}这些改进可以提高代码的可读性、可维护性,并减少潜在的错误。同时,通过添加输入验证和封装特殊逻辑,可以增强代码的健壮性和安全性。 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideExtend the CPU frequency correction logic in DeviceCpu::setCpuInfo to include kSpecialType7 devices, ensuring the same frequency and max-frequency replacements apply to correct hardware reporting inaccuracies. Class diagram for updated DeviceCpu frequency correction logicclassDiagram
class DeviceCpu {
- m_Name : QString
- m_Frequency : QString
- m_MaxFrequency : QString
+ setCpuInfo(mapLscpu: QMap<QString, QString>, mapCpuinfo: QMap<QString, QString>)
}
class Common {
+ specialComType : int
+ kSpecialType5 : int
+ kSpecialType6 : int
+ kSpecialType7 : int
}
DeviceCpu --> Common : uses
DeviceCpu : setCpuInfo() now applies frequency correction for kSpecialType7
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
max-lvs
approved these changes
Sep 15, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, max-lvs 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.
Modified CPU frequency display for kSpecialType7 devices include current frequency and max frequency to correct hardware reporting inaccuracies.
Log: Fix CPU frequency display for special device type
Task: https://pms.uniontech.com/task-view-381765.html
Change-Id: Id37a4b03a83ccb6428a1bd3edf601d905edbd2c8
Summary by Sourcery
Include special device type7 in the CPU frequency correction logic to ensure accurate display of current and maximum frequencies.
Bug Fixes: