Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
#include <QString>
#include <QMap>

#include <sys/utsname.h>

Check warning on line 12 in deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/commonfunction.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <sys/utsname.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

static QMap<QString, QString> mapArch = { {"aarch64", "arm64"}
static QMap<QString, QString> mapArch = {
{"aarch64", "arm64"}
, {"x86_64", "amd64"}
, {"mips64", "mips64el"}
, {"i386", "i386"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void MainJob::updateAllDevice()
qCDebug(appLog) << "Updating existing device info";
m_pool->updateDeviceInfo();
}
m_pool->waitForDone(-1);
Copy link

Choose a reason for hiding this comment

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

issue: Introducing a 60s wait timeout may leave device updates incomplete without any handling.

Changing waitForDone from infinite to 60s changes behavior: if the pool is still busy after 60s, we return and still set m_firstUpdate to false, treating the update as complete. For long-running updates, this can leave device info partially updated with no signal to the caller. Consider either making the timeout configurable, or explicitly handling a timeout (if the pool API supports it), e.g. by logging it, not clearing m_firstUpdate, retrying, or otherwise surfacing an error state.

m_pool->waitForDone(60000);
PERF_PRINT_END("POINT-01");
m_firstUpdate = false;
}
Expand Down
7 changes: 7 additions & 0 deletions deepin-devicemanager/src/DeviceManager/DeviceCpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ void DeviceCpu::setCpuInfo(const QMap<QString, QString> &mapLscpu, const QMap<QS
m_Name.replace(QRegularExpression("x [0-9]*$"), "");
qCDebug(appLog) << "CPU name after regex replacement: " << m_Name;

if (Common::specialComType == Common::kSpecialType5 ||
Common::specialComType == Common::kSpecialType6 ||
Common::specialComType == Common::kSpecialType7) {
m_Frequency = m_Frequency.replace("2.189", "2.188");
m_MaxFrequency = m_MaxFrequency.replace("2189", "2188");
}
Comment on lines +56 to +61
Copy link

Choose a reason for hiding this comment

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

suggestion (bug_risk): Consider making the frequency replacement more robust and avoiding the redundant assignment.

In this block:

  1. QString::replace mutates in place and returns a reference, so m_Frequency = m_Frequency.replace(...) / m_MaxFrequency = ... is redundant. A simple m_Frequency.replace("2.189", "2.188"); is enough.

  2. The replacement for "2189" is very broad and will also hit occurrences inside longer values (e.g. 12189, 21890) or in other fields if the format changes. If you only intend to adjust a specific frequency value, consider tightening the match (e.g. more constrained pattern/regex or validating the whole field before replacing) to avoid unintended substitutions.

Suggested change
if (Common::specialComType == Common::kSpecialType5 ||
Common::specialComType == Common::kSpecialType6 ||
Common::specialComType == Common::kSpecialType7) {
m_Frequency = m_Frequency.replace("2.189", "2.188");
m_MaxFrequency = m_MaxFrequency.replace("2189", "2188");
}
if (Common::specialComType == Common::kSpecialType5 ||
Common::specialComType == Common::kSpecialType6 ||
Common::specialComType == Common::kSpecialType7) {
// Avoid broad substring replacements: only adjust when the full value matches.
if (m_Frequency == "2.189") {
m_Frequency = "2.188";
}
if (m_MaxFrequency == "2189") {
m_MaxFrequency = "2188";
}
}


// 获取逻辑数和core数
m_LogicalCPUNum = logicalNum;
m_CPUCoreNum = coreNum;
Expand Down
6 changes: 4 additions & 2 deletions deepin-devicemanager/src/DeviceManager/DeviceOthers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ void DeviceOthers::setInfoFromLshw(const QMap<QString, QString> &mapInfo)
setAttribute(mapInfo, "maxpower", m_MaximumPower);
setAttribute(mapInfo, "speed", m_Speed);
setAttribute(mapInfo, "logical name", m_LogicalName);

if (m_Driver.toLower() == "usbfs")
m_Driver.clear();
if(m_Driver.isEmpty() && !m_Avail.compare("yes", Qt::CaseInsensitive)){
qCDebug(appLog) << "DeviceOthers::setInfoFromLshw, driver is empty and avail is yes";
setForcedDisplay(true);
Expand Down Expand Up @@ -99,7 +100,8 @@ void DeviceOthers::setInfoFromHwinfo(const QMap<QString, QString> &mapInfo)
setAttribute(mapInfo, "Module Alias", m_Modalias);
setAttribute(mapInfo, "VID_PID", m_VID_PID);
m_PhysID = m_VID_PID;

if (m_Driver.toLower() == "usbfs")
m_Driver.clear();
if (mapInfo["Hardware Class"] != "fingerprint") {
qCDebug(appLog) << "DeviceOthers::setInfoFromHwinfo, hardware class is not fingerprint";
m_HardwareClass = "others";
Expand Down
4 changes: 2 additions & 2 deletions deepin-devicemanager/src/Tool/DBusAnythingInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class DBusAnythingInterface : public QObject

private:
static std::atomic<DBusAnythingInterface *> s_Instance;
static std::mutex m_mutex;
QDBusInterface *mp_Iface;
static std::mutex m_mutex;
QDBusInterface *mp_Iface;
};

#endif // DBUSANYTHINGINTERFACE_H
4 changes: 2 additions & 2 deletions deepin-devicemanager/src/Tool/EDIDParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ class EDIDParser
private:
/**@brief:机器的存储模式不同,会导致计算结果不同,所以在解析的时候需要考虑大小端模式*/
QString m_Vendor; // 显示屏的厂商信息
QString m_Model; // 显示屏的型号信息
QString m_Model; // 显示屏的型号信息
QString m_ReleaseDate; // 显示屏的生产日期
QString m_ScreenSize; // 屏幕大小
QString m_MonitorName; // 监视器名称
bool m_LittleEndianMode; // 小端模式
int m_Width; // width
int m_Height; // heigth
QStringList m_ListEdid; // edid数据
QMap<QString, QString> m_MapCh; //
QMap<QString, QString> m_MapCh; // 二进制字符串映射到字母A-Z


};
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/Tool/ThreadExecXrandr.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ThreadExecXrandr : public QThread
private:
bool m_Gpu; //<! 判断是否是gpu
bool m_isDXcbPlatform; //<! 判断是否是DXcbPlatform
QStringList m_monitorLst;
QStringList m_monitorLst; //<! DBus中反馈的显示器列表
};

#endif // THREADEXECXRANDR_H
3 changes: 1 addition & 2 deletions deepin-devicemanager/src/Tool/commontools.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public slots:
static QMap<DriverType, QString> m_MapDriverType;
static QMap<Status, QString> m_MapStatusIcon;
static QMap<Status, QString> m_MapStatusType;

static QMap<int, QString> m_MapErrorString;
static QMap<int, QString> m_MapErrorString;
};

#endif // COMMONTOOLS_H
5 changes: 3 additions & 2 deletions deepin-devicemanager/src/commonfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

using namespace DDLog;

static QMap<QString, QString> mapArch = { {"aarch64", "arm64"}
static QMap<QString, QString> mapArch = {
{"aarch64", "arm64"}
, {"x86_64", "amd64"}
, {"mips64", "mips64el"}
, {"i386", "i386"}
Expand Down Expand Up @@ -165,7 +166,7 @@ QString Common::checkBoardVendorFlag()
case PGUV:
boardVendorKey = "PGUV";
break;
case PGUX:
case kSpecialType5:
boardVendorKey = "PGUX";
break;
case kCustomType:
Expand Down
2 changes: 1 addition & 1 deletion deepin-devicemanager/src/commonfunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Common
KLVV,
KLVU,
PGUV,
PGUX,
kSpecialType5,
kSpecialType6,
kSpecialType7,
kCustomType
Expand Down