feat: [GPU] Add logic to show GPU info.#566
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom Dec 1, 2025
Merged
feat: [GPU] Add logic to show GPU info.#566deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
-- In some special computer, the GPU info not show. -- Add logic to show GPU info. pick from: linuxdeepin@350c0a6 Log: add feature for GPU. Task: https://pms.uniontech.com/task-view-378987.html
deepin pr auto review我来对这段代码进行审查:
a) 错误处理: // 在getGpuMemInfoForFTDTM函数中
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qCritical() << "Error opening /sys/kernel/debug/gc/meminfo:" << file.errorString();
return false;
}建议添加文件权限检查,因为访问/sys/kernel/debug/需要root权限。 b) 内存管理: // 在CustomGenerator::generatorGpuDevice中
DeviceGpu *device = new DeviceGpu();建议使用智能指针(QSharedPointer)管理内存,避免内存泄漏。 c) 安全性: // 在getGpuInfoByCustom函数中
process.start(cmd, arguments);建议对cmd参数进行验证,防止命令注入攻击。 d) 性能优化: // 在getGpuMemInfoForFTDTM中
QRegularExpression system0Regex(R"(POOL SYSTEM0:*(.*?)POOL VIRTUAL:)",
QRegularExpression::DotMatchesEverythingOption);建议将正则表达式编译为静态常量,避免重复编译。 e) 代码健壮性: // 在getGpuMemInfoForFTDTM中
if (ok && memSize >= 1048576) {
memSize /= 1048576;
auto curSize = memSize / 1024.0;
if (curSize >= 1) {
totalValue = QString::number(curSize) + "GB";
} else {
totalValue = QString::number(memSize) + "MB";
}
}建议添加边界检查,防止数值溢出。
总体来说,代码结构清晰,功能完整,但在错误处理、内存管理和安全性方面还有改进空间。建议按照上述建议进行优化,以提高代码的健壮性和安全性。 |
lzwind
approved these changes
Dec 1, 2025
|
[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
|
/forcemerge |
Contributor
|
This pr force merged! (status: unstable) |
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.
-- In some special computer, the GPU info not show. -- Add logic to show GPU info.
pick from: 350c0a6
Log: add feature for GPU.
Task: https://pms.uniontech.com/task-view-378987.html