Skip to content
Open
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 @@ -13,9 +13,10 @@
#include <QFile>
#include <QLoggingCategory>

#include <sys/utsname.h>

Check warning on line 16 in deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/utils.cpp

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.
#include <unistd.h>

Check warning on line 17 in deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/utils.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <fcntl.h>

Check warning on line 18 in deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/utils.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <errno.h>

Check warning on line 19 in deepin-devicemanager-server/deepin-devicecontrol/src/drivercontrol/utils.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

using namespace DDLog;

Expand Down Expand Up @@ -216,7 +217,12 @@
int fd = open(filepath.toStdString().c_str(), opentype);
//文件打开失败默认为被锁住

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nitpick: The comment immediately before the branch says every open() failure is treated as locked, but the new ENOENT branch returns false, so the comment now describes behavior that is no longer true and can mislead future maintenance.

Suggested fix: Update the comment to state that non-ENOENT open() failures are conservatively treated as locked.

Suggested change
//文件打开失败默认为被锁住
//除ENOENT外的文件打开失败,保守起见视为被锁住

if (fd < 0) {
return true;
if (errno == ENOENT) {
//文件不存在,未被锁定
return false;
}
//其他原因无法打开文件,保守起见视为已锁定
return true;
}

if (-1 == fcntl(fd, F_SETLK, &fl)) {
Expand Down
Loading